Support: Android initialization error: PlatformException(flutter_stripe initialization failed) #538
Replies: 71 comments 95 replies
-
|
Hi I'm unable to make it work on android. It was working perfectly with version 2.1.0, but know it is not with 2.1.1. I tried downgrading but no result. My styles are exactly the same as the examples. The error I get is as soon as the app starts, the moment I apply the settings: [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(flutter_stripe initialization failed, The plugin failed to initialize: |
Beta Was this translation helpful? Give feedback.
-
|
please help me. |
Beta Was this translation helpful? Give feedback.
-
|
Ok I solved my issue, I leave it here in case someone is having the same problem. It was my mistake, I'm using flavors in my project, so I have a dev folder inside "android/app/src" called "dev" that gets copied to replace the "android/app/src/main/res" folder with dev assets, among them there was new styles.xml So I had to update does files also to the theme requested by Stripe. A simple thing to forget. Hope it helps someone. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
hello, I installed flutter_stripe package and everything is working fine, but while uing cardfield(), if i go back with navigator.pop(context) it says 'java.lang.RuntimeException: Error during attachToGLContext' and app is closing, how to solve this error, it happens only when i use cardfield. |
Beta Was this translation helpful? Give feedback.
-
|
I'm facing an issue with a few of my Android users, it seems to be random and I'm unable to reproduce in the devices I try. Here is what I have on my app/main/res/values/styles.xml, which seems okay when I compare to the example in this repository. <?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<style name="NormalTheme" parent="Theme.MaterialComponents">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>Have I forgotten something or is anyone else facing the same issue? |
Beta Was this translation helpful? Give feedback.
-
|
Any update on this one? |
Beta Was this translation helpful? Give feedback.
-
|
flutter_stripe: ^2.4.0 Still same error after whole day search. please update any solution. even 100% follow the steps. `e: C:\flutter.pub-cache\hosted\pub.dartlang.org\stripe_android-2.4.0\android\src\main\kotlin\com\flutter\stripe\StripeSdkGooglePayButtonPlatformViewFactory.kt: (13, 1): Class 'StripeSdkGooglePayButtonPlatformViewFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactory FAILURE: Build failed with an exception.
|
Beta Was this translation helpful? Give feedback.
-
|
FAILURE: Build failed with an exception. What went wrong: |
Beta Was this translation helpful? Give feedback.
-
|
Found solution : change ndkVersion "23.1.7779620" instead ndkVersion flutter.ndkVersion environment: sdk: ">=2.16.2 <3.0.0" |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I am getting the same error on Android over and over again. I have followed every step at the readme. Error on build timeFAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processProductionDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
> Android resource linking failed
ERROR:AAPT: error: resource style/Theme.AppCombat.Light.NoActionBar (aka app.diven:style/Theme.AppCombat.Light.NoActionBar) not found.
error: resource style/Theme.AppCombat.Light.NoActionBar (aka app.diven:style/Theme.AppCombat.Light.NoActionBar) not found.
error: failed linking references.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 58s
Exception: Gradle task assembleProductionDebug failed with exit code 1Flutter doctorDoctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.5, on macOS 11.6 20G165 darwin-x64, locale es-ES)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.66.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
• No issues found!styles.xmlI have 3 flavors:
values/ folder: <?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting -->
<style name="LaunchTheme" parent="Theme.AppCombat.Light.NoActionBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowFullscreen">false</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="Theme.MaterialComponents">
<item name="android:windowBackground">@android:color/white</item>
</style>
</resources>values-night/ folder: <?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="Theme.AppCombat.Light.NoActionBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowFullscreen">false</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="Theme.MaterialComponents">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>MainActivity.ktpackage com.example.divenApp
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity: FlutterFragmentActivity() {
}
android > build.gradlebuildscript {
ext.kotlin_version = '1.5.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.8'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}Can you help me? If there is any missing information I could add lmk EDIT: Solution on my comment below |
Beta Was this translation helpful? Give feedback.
-
|
FAILURE: Build failed with an exception. What went wrong: Flutter version : 3.0 |
Beta Was this translation helpful? Give feedback.
-
|
try this |
Beta Was this translation helpful? Give feedback.
-
|
changes values-v31 -> Theme.MaterialComponents its working for me |
Beta Was this translation helpful? Give feedback.
-
|
I have found solution it might not work changing only values/styles.xml |
Beta Was this translation helpful? Give feedback.
-
Please I need an assistance, because I have been getting: |
Beta Was this translation helpful? Give feedback.
-
|
HI! I am having this issue: bad class file: C:\Users\XXXXX\StudioProjects\XXXX\build\stripe_android\intermediates\compile_library_classes_jar\debug\bundleLibCompileToJarDebug\classes.jar(com/flutter/stripe/StripeAndroidPlugin.class) |
Beta Was this translation helpful? Give feedback.
-
|
hey i just build my flutter application i add the stripe package it work paerfecly but the problem i didn't know how to make it is i use express js for my backend and i don't know really how to connect or make the integration using these two implementation is there anyone who make it with also using the webhooks |
Beta Was this translation helpful? Give feedback.
-
|
Please Help !! |
Beta Was this translation helpful? Give feedback.
-
|
I'm having this problem, please assist. |
Beta Was this translation helpful? Give feedback.
-
|
Your Main Activity class io.flutter.embedding.android.FlutterActivity is not a subclass FlutterFragmentActivity |
Beta Was this translation helpful? Give feedback.
-
|
Hi, i have some trouble. Do you guy's have any idea ?
Thank you in advance |
Beta Was this translation helpful? Give feedback.
-
|
i have this error : I/flutter (10293): Error while creating payment method: PlatformException(flutter_stripe initialization failed, The plugin failed to initialize: this is my styles :
and this is my manifest :
but i still cant work Stripe , any suggestion? |
Beta Was this translation helpful? Give feedback.
-
|
I have the same problem and i have solved this by this way, and this worked for me my style are ` |
Beta Was this translation helpful? Give feedback.
-
|
PlatformException(flutter_stripe initialization failed, |
Beta Was this translation helpful? Give feedback.
-
|
Hello, jitsi_meet_flutter_sdk: ^10.3.0 Thanks ERROR: /Users/pierreadopre/Projects/mobile/lecturoom/build/stripe_android/intermediates/runtime_library_classes_jar/release/bundleLibRuntimeToJarRelease/classes.jar: R8: Type com.facebook.react.bridge.Callback is defined multiple times: /Users/pierreadopre/Projects/mobile/lecturoom/build/stripe_android/intermediates/runtime_library_classes_jar/release/bundleLibRuntimeToJarRelease/classes.jar:com/facebook/react/bridge/Callback.class, /Users/pierreadopre/.gradle/caches/8.10.2/transforms/7746049ef94a9dd1cd7944e2e4362d3d/transformed/jetified-react-android-0.75.4-release-runtime.jar:com/facebook/react/bridge/Callback.class FAILURE: Build failed with an exception.
|
Beta Was this translation helpful? Give feedback.
-
|
This worked for me, add androidmanifest.xml
|
Beta Was this translation helpful? Give feedback.
-
|
Hi, I am a beginner coder and I am in the late stages of launching my app. This is my very first time posting on github so please bear with me! I am using flutter_stripe version 9.6.0, as it's the latest version compatible with my project. This requires me to use: stripe-android:20.37.1 kotlin:1.9.24 compose:1.5.14 I followed all the steps in the README.md for flutter_stripe 9.6.0. However, every time I try to use the PaymentSheet, my Android app crashes with a NoSuchMethodError. Error Log: `E/AndroidRuntime( 6843): FATAL EXCEPTION: main E/AndroidRuntime( 6843): at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3148) E/AndroidRuntime( 6843): at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:600) E/AndroidRuntime( 6843): at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:278) E/AndroidRuntime( 6843): at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2103) E/AndroidRuntime( 6843): at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1998) E/AndroidRuntime( 6843): at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1941) E/AndroidRuntime( 6843): at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:661) E/AndroidRuntime( 6843): at android.os.Handler.handleCallback(Handler.java:995) E/AndroidRuntime( 6843): at android.os.Handler.dispatchMessage(Handler.java:103) E/AndroidRuntime( 6843): at android.os.Looper.loopOnce(Looper.java:248) E/AndroidRuntime( 6843): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 6843): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) E/AndroidRuntime( 6843): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) W/FirebaseCrashlytics( 6843): Timeout exceeded while awaiting app exception callback from Analytics listener. I/Process ( 6843): Sending signal. PID: 6843 SIG: 9 Lost connection to device.` Flutter Code (Checkout Screen): dart Android app/build.gradle: gradle } dependencies { } properties Kotlin settingskotlin.code.style=official pro ... other rules ...========== STRIPE PROGUARD RULES ==========-keep class com.stripe.android.** { ; } -dontwarn com.stripe.android.** PaymentSheet specific rules-keep class com.stripe.android.paymentsheet.** { *; } Remove conflicting exclusions-dontwarn com.stripe.android.pushProvisioning.**I'd really appreciate if I could get some help ASAP! This is literally the last thing stopping me from launching my app. Thank you so much! :) |
Beta Was this translation helpful? Give feedback.
-
|
when use package with jitsi_meet_flutter_sdk: ^11.5.1 |
Beta Was this translation helpful? Give feedback.
-
How I Fixed "flutter_stripe initialization failed" on Android - A Complete GuideIf you've been banging your head against the wall trying to get Flutter Stripe to work on Android, you're not alone. I spent hours debugging this issue and I'm sharing everything I learned so you don't have to. The ErrorYou're probably seeing something like this in your logs: Or this one: Let's fix it step by step. Step 1: Fix MainActivityThe Stripe SDK uses Android's Fragment APIs for the payment sheet UI. Flutter's default Open // Before
package com.yourapp
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity()To: // After
package com.yourapp
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity: FlutterFragmentActivity()That's it for this file. Simple change, but absolutely required. Step 2: Fix the Theme (This is where it gets tricky)Here's what caught me off guard - Flutter creates multiple Check your
The Update all styles.xml filesFor <?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
<style name="NormalTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>For <?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
<style name="NormalTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>The key change is replacing Step 3: Add the DependenciesThe theme references dependencies {
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
}Add this at the end of the file if you don't have a Step 4: Clean Build (Don't Skip This!)This is crucial. The changes won't take effect if you just hot reload or even hot restart. You need a full clean build. flutter clean
cd android
gradlew clean # Use ./gradlew clean on Mac/Linux
cd ..
flutter pub get
flutter runIf it still doesn't work, uninstall the app from your device/emulator completely, then run the commands again. Android caches things aggressively and sometimes that's the only way to clear it. Quick ChecklistBefore you start debugging again, make sure you have:
Why Does This Happen?The Stripe Android SDK uses native Android UI components (specifically
Flutter's default configuration doesn't include these because most Flutter apps don't need native Android UI components - everything is rendered by Flutter's engine. But payment SDKs like Stripe need to display native UI for security and compliance reasons. Final ThoughtsThe Flutter Stripe documentation does mention these requirements, but it's easy to miss the part about multiple Hope this saves you the hours I spent debugging. If it helped, feel free to share it with other developers stuck on the same issue. Happy coding! |
Beta Was this translation helpful? Give feedback.



Uh oh!
There was an error while loading. Please reload this page.
-
Are you having trouble making the Flutter Stripe work on Android? This discussion is to give support for this specific problem.
We are aware that the process is a bit more complex than desired but it is out of our hands here.
Please make sure you check again and follow all the steps in the readme before posting here.
Beta Was this translation helpful? Give feedback.
All reactions