我在颤振应用中实现了条形支付系统,我出错了
PlatformException (PlatformException(flutter_stripe initialization failed, The plugin failed to initialize:
Your Main Activity class com.example.eres.MainActivity is not a subclass FlutterFragmentActivity.
Please make sure you follow all the steps detailed inside the README: https://github.com/flutter-stripe/flutter_stripe#android
If you continue to have trouble, follow this discussion to get some support https://github.com/flutter-stripe/flutter_stripe/discussions/538, null, null))当我运行app时,什么会导致这个错误,我在下面发送另一个文件,错误出现在等待Stripe.instance.applySettings()所在的位置,如果我删除它,我会再次得到相同的错误。
Main.dart -主要功能
void main() async {
HttpOverrides.global = new MyHttpOverrides();
WidgetsFlutterBinding.ensureInitialized();
Stripe.publishableKey =
"pk_test_51LS4cRFZdZe5rLR6wpNk9gLGUxCtdm8kIaymO3CifwTxihGUdSTyRmIl0ipk4rYMfHTdNVBoBmgLbSpCP6IrCzV500wcxqU1Hv";
await Stripe.instance.applySettings();
runApp(MyApp());
}pubspec.yaml
name: eres
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.17.1 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
http: ^0.13.4
loading_animation_widget: ^1.2.0+2
provider: ^6.0.3
flutter_switch: ^0.3.2
json_annotation: ^4.6.0
flutter_map: ^2.2.0
latlong2: ^0.8.0
flutter_local_notifications: ^9.7.0
flutter_stripe: ^2.0.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
assets:
- assets/images/Android/build.gradle
buildscript {
ext.kotlin_version = '1.5.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}如果您对此有任何建议,请评论,非常感谢。
发布于 2022-09-02 08:24:03
在你的安卓的MainActivity文件中,它应该扩展FlutterFragmentActivity。AppFolder -> Android ->应用程序-> src -> kotlin -> com.xxx.xxx -> MainActivity
class MainActivity : FlutterFragmentActivity() {
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine)
{
// Your code
}
}https://stackoverflow.com/questions/73345618
复制相似问题