-
-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android App crashes in Release mode with com.android.application version >= 8 #1909
Comments
so deadobject exception means the paymentsheetactivity got killed by the android OS. Can it be that you do not have applied all the steps for android as described here? I am using paymentsheet as well and do not have this issue |
Yes @remonh87, I have done all the steps like in the instruction and getting:
Now, please look at my configuration and see if you can spot anything:
Pubspec.yaml: name: goxp
description: GoXP app
publish_to: 'none'
version: 0.2.0+154
environment:
sdk: '>=3.5.0 <4.0.0'
dependencies:
flutter:
sdk: flutter
amplify_api: ^2.3.0
amplify_auth_cognito: ^2.3.0
amplify_authenticator: ^2.1.1
amplify_flutter: ^2.3.0
badges: ^3.1.1
collection: ^1.18.0
cupertino_icons: ^1.0.2
equatable: ^2.0.5
flutter_native_splash: ^2.3.1
flutter_rating_bar: ^4.0.1
flutter_redux: ^0.10.0
flutter_stripe: ^11.0.0
form_builder_validators: ^11.0.0
go_router: ^14.2.0
http_parser: ^4.0.2
http: ^1.1.0
image_picker: ^1.0.4
mocktail: ^1.0.3
redux: ^5.0.0
settings_ui: ^2.0.2
url_launcher: ^6.3.0
uuid: ^4.3.3
dev_dependencies:
integration_test:
sdk: flutter
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.13.1
flutter_lints: ^4.0.0
change_app_package_name: ^1.2.0
flutter:
uses-material-design: true
assets:
- assets/images/
- assets/images/initialisation/
- assets/icons/
fonts:
- family: Poppins
fonts:
- asset: assets/fonts/poppins/Poppins-Thin.ttf
weight: 100
- asset: assets/fonts/poppins/Poppins-ThinItalic.ttf
weight: 100
style: italic
- asset: assets/fonts/poppins/Poppins-ExtraLight.ttf
weight: 200
- asset: assets/fonts/poppins/Poppins-ExtraLightItalic.ttf
weight: 200
style: italic
- asset: assets/fonts/poppins/Poppins-Light.ttf
weight: 300
- asset: assets/fonts/poppins/Poppins-LightItalic.ttf
weight: 300
style: italic
- asset: assets/fonts/poppins/Poppins-Regular.ttf
- asset: assets/fonts/poppins/Poppins-Italic.ttf
style: italic
- asset: assets/fonts/poppins/Poppins-Medium.ttf
weight: 500
- asset: assets/fonts/poppins/Poppins-MediumItalic.ttf
weight: 500
style: italic
- asset: assets/fonts/poppins/Poppins-SemiBold.ttf
weight: 600
- asset: assets/fonts/poppins/Poppins-SemiBoldItalic.ttf
weight: 600
style: italic
- asset: assets/fonts/poppins/Poppins-Bold.ttf
weight: 700
- asset: assets/fonts/poppins/Poppins-BoldItalic.ttf
weight: 700
style: italic
- asset: assets/fonts/poppins/Poppins-ExtraBold.ttf
weight: 800
- asset: assets/fonts/poppins/Poppins-ExtraBoldItalic.ttf
weight: 800
style: italic
- asset: assets/fonts/poppins/Poppins-Black.ttf
weight: 800
- asset: assets/fonts/poppins/Poppins-BlackItalic.ttf
weight: 800
style: italic
flutter_launcher_icons:
image_path: "assets/icons/app_icon.png"
android: true
ios: true
adaptive_icon_background: "assets/icons/background.png"
adaptive_icon_foreground: "assets/icons/foreground.png"
flutter_native_splash:
color: "#0D0160"
color_dark: "#0D0160"
image_ios: assets/images/splash/splash.png
ios_content_mode: scaleAspectFill
android_12:
image: android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
image_android: assets/images/splash/splash.png
android_gravity: center main.dart: Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
Stripe.publishableKey =
"pk_test_*********";
Stripe.merchantIdentifier = 'merchant.flutter.stripe.test';
Stripe.urlScheme = 'goxpdev';
await Stripe.instance.applySettings();
...
runApp(...);
} styles.xml: <?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 off -->
<style name="LaunchTheme" parent="Theme.AppCompat.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>
</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> styles.xml (values-night): <?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 -->
<!-- TODO document the necessary change -->
<style name="LaunchTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</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> android/build.gradle: allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
} android/app/build.gradle: plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "com.google.gms.google-services"
id "com.google.firebase.crashlytics"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
namespace "com.gameos.goxp.dev"
compileSdk 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.gameos.goxp.dev"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 24
targetSdkVersion 33
// targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
flutter {
source '../..'
}
dependencies {
implementation 'com.google.firebase:firebase-iid:21.1.0'
implementation 'com.google.android.gms:play-services-base:18.1.0'
} proguard-rules.pro:
gradle-wraper.properties:
MainActivity.kt: package com.gameos.goxp.dev
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity: FlutterFragmentActivity() {
} and the code that is presenting the payment sheet: Future<void> _bookCurrentExperience(Store<AppState> store, BookCurrentExperience action, NextDispatcher next) async {
store.dispatch(const ShowLoader());
try {
final experienceId = store.state.experienceState.currentExperience!.id;
final priceOptionId = action.priceOptionId;
final experienceModifiedAt = store.state.experienceState.currentExperience!.modifiedAt;
// 1. create payment intent on the server
final paymentIntent = await _createPaymentIntent(experienceId, priceOptionId, experienceModifiedAt);
// 2. set publishable key
// Stripe.publishableKey = paymentIntent.publishableKey;
// 3. initialize the payment sheet
await Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
customFlow: false,
merchantDisplayName: 'GoXP',
paymentIntentClientSecret: paymentIntent.clientSecret,
customerEphemeralKeySecret: paymentIntent.ephemeralKey,
customerId: paymentIntent.stripeCustomerId,
),
);
// 4. present payment sheet
await Stripe.instance.presentPaymentSheet();
safePrint("Payment completed!!!");
// TODO: navigate to "Thank for booking your experience. Check your inbox for a confirmation email"
next(action);
} catch (e) {
// TODO: show a popup with an error message
safePrint(e);
} finally {
store.dispatch(const HideLoader());
}
} I am running out of ideas. I tried lots of things like fiddling with Once again, the Debug build works, but the Release/Prod build fails, as shown in the log at the top. Please help. |
@lokus1980 can u please provide an image for settings.gradle file, and there are 3 things to try android/build.gradle:
|
Hi @ibrahimMobileArts, I have applied your suggested changes and the app is still crashing. Here's the content of my
I think there must be some weird bug in this library as, like I said, the app works in a Debug build (so all settings, libs and things are like they should) but in a Release build it crashes when I try to shoe the Payment Sheet. I don't know what else I can do to make it work in Release build. I'll try to run the demo app included in this library whether it works in Release build as if it suffers from the same problem, you would have a case that is easy to reproduce on your end. Also, what did you mean exactly by "first you should know that there is an updated syntax for this whole file"? |
OK, the demo app (that is included in this library) crashes at the same point as my app. I just launched the server and then the app, went to the payment sheet screen and it crashes with my test Stripe keys: Here's the video of the crash: So the problem seems to be in the library, not in my app. Please launch the demo app in a Release mode and you will see the crash on your end too :) Just try |
this is an example, even though i don't think its the problem anymore: def localProperties = new Properties() def flutterVersionCode = localProperties.getProperty("flutter.versionCode") def flutterVersionName = localProperties.getProperty("flutter.versionName") android {
} flutter { dependencies { // Add the dependencies for any other desired Firebase products |
Hi @ibrahimMobileArts and @remonh87. As in my previous message, the demo app included in this library crashes the same way as my app in Release mode. I have tested it both with Stripe test and live API keys. That's a serious bug I think. It crashes the same way on emulators and real devices (like a stock Google Pixel 6 with Android 14). This makes this Flutter library unusable in production. Can you please run the demo app in Release mode (
And that's my flutter doctor report again if that helps:
Also, my Java (as maybe here there's something wrong?):
|
@lokus1980 hello, sorry am not sure about your problem exactly, however please try few things i foundx while comparing to my working code:
|
Hi @ibrahimMobileArts, before I try your suggestions, can you please check a few things for me? The video you saw in my previous message is not from my app but the demo app included in this library. It's crashing on all my Android phones too. Please download it here: https://github.com/flutter-stripe/flutter_stripe/tree/main/example
|
@lokus1980 i just finished running my app using flutter run --release and i made a payment and everything works fine, did you try the library's demo app on android 12 or below? |
Thank you @ibrahimMobileArts for checking this! Are you making payments in your app via Payment Sheet (https://docs.page/flutter-stripe/flutter_stripe/sheet)? Can you please share what Flutter and Java version you have on your machine? Are you running everything on Mac or Windows? |
Flutter 3.24.1 / Dart 3.5.1 |
Thank you, I'll try your Java version and see if that helps. The rest is the same as on my machine. |
I tried some older versions of Java, and also a phone with Android 12. It is still crashing when showing a Payment Sheet. I am running out of ideas 😬 Is there an alternative method of making a payment by card in this library? |
I can reproduce it on the example app. Will spend some time tonight to see if I can fix something. Can you try an older version of Flutter Stripe. The interesting thing is that I cannot reproduce it in my other production app so it has to be some config somewhere CC: @jonasbark |
@lokus1980 so it looks like some gradle / android dependency issue. I didn't came further in our repo but I was able to run release with a paymentsheet with a fresh flutter project. Feel free to have a look and compare: https://github.com/remonh87/test_app_stripe . I will look a bit further later this week to triage it further but it is a needle in a haystack |
Thanks @remonh87 so much for being able to reproduce the issue on your end. It's a relief that it's not only happening on my machine/phones only. I'll try to compare the demo app with your one (that works in the release build) to understand what is causing this issue. If we find it, let's fix the demo app for others 😉 |
Hi @remonh87 - great success! By comparing your app with the demo one, I have found the issue. It all comes down to this change to make the app work in release mode. So it was |
Thanks for investigating @remonh87 @lokus1980 ! I'll dig deeper the next few days as that required change is a bit concerning |
I did get another crash when running the latest example app in release mode:
and using the latest stripe-android 20.49.0 version:
Downgrading com.android.application is indeed the only fix I found. |
Yes, that is a bit concerning @jonasbark but because a freshly generated Flutter app with the latest Flutter version uses So it does not necessarily mean that flutter_stripe has some bug but it's a general Flutter issue that is not really compatible with The only things I would do for now are to:
|
@jonasbark - I have created a branch with the fixes mentioned above but I don't have permissions to push that branch and create a pull request. Can you please help? |
Most libraries are requiring to have
as well as Java version at least 17 or newer, not 1.8 @ibrahimMobileArts https://docs.gradle.org/current/userguide/compatibility.html |
The app crashes with such gradle plugin settings
Gradle 7.4 |
The app was running smoothly now i suddenly started getting this error even though no changes were made A problem occurred configuring project ':stripe_android'.
|
We added a warning in the latest stripe android plugin that was released yesterday. Problem is that if you have a higher gradle plugin it can crash the app with issues mentioned above. We have to wait on Stripe to bump their Android dependencies in the sdk. |
So what would be the recommendations for As i tried downgrading but i got other issues Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times. |
I had same problem, using latest flutter version. Now working:
|
Do i have to delete the android folder as i have configs for other as well |
In the new version flutter_stripe: ^11.2.0 Update buildscript {
dependencies {
classpath "com.android.tools.build:gradle:7.4.2"
}
} |
Okay so tried everything Downgrading the gradle version not compatible Can we get a details on when the issue will be fixed? |
Downgrading gradle worked for me. In gradle-wrapper.properties i used this: distributionUrl=https://services.gradle.org/distributions/gradle-7.6.3-all.zip and then in the settings.gradle plugins, this: id "com.android.application" version '7.4.2' apply false |
Hello, anyone can help me because I upgrade flutter_stripe: ^11.1.0 to flutter_stripe: ^11.2.0, then for running in android I got error: ###settings.gradle: ###Gradle-wrapper.properties: ###Error:
|
I found easy solution which is will be fix your problem with flutter_stripe: ^11.2.0 Add stripe_android: 11.0.0 inside dependency_overrides in pubspec.yaml dependency_overrides: May you need in the future: Enjoy |
As the build error already states the single line you'll likely need to adjust is downgrading the com.android.application plugin to e.g. 7.3.0. You can find a working example here: |
Can you name some that are incompatible? |
@alipilot149 then you're still stuck with the issue we have here. Does your Android app crash in release mode when opening the Stripe Payment Sheet? |
No, it works great |
I'm glad it works for you. I tried your combination and it still crashes in release version:
|
These versions for me works: plugins { and: dependency_overrides: I wish these info may help you to set correctly. |
I just released stripe_android in version 11.2.1 that no longer errors out when com.android.application gradle plugin > 8.0.0 is used. For anyone facing OPs issue: the only reliable way I found to still make it work when your app crashes is
|
Hello, Is this issue resolved ? I don't seem to face any issue in release mode, using :
And without any dependency override. I did not face the issue myself previously but came accross this issue from the README doc while upgrading my project dependencies and migrating to AGP 8+. |
I was facing a big trouble for two days after I upgrade to Channel stable, 3.24.4,, it was crashing in the release mode and when I fix it , then it crashes in the debug mode , so finally I create a new project with the same name and I moved all my folder to it , and finally it works great with (distributionUrl=https://services.gradle.org/distributions/gradle-8.7-bin.zip), and every think looks great , I am using flutter_stripe 11.2.0. I hope this will be a good information. |
I've tried downgrading and upgrading, but nothing seems to work in release mode . I keep getting the following error. fluter_stripe 11.2.0
|
Hi all, are there any new updates for this matter? I also have now upgraded to gradle 8.7 based upon the comments above and still crashing on release mode upon using the payment sheet using flutter_stripe 11.2.0. Are there any other current workarounds other than to set these two to false? I also attempted to set to dependency_overrides: But this still crashes. Thank you. |
@lokus1980 it looks like the issue is resolved now with the latest version. can you verify it works on your end? |
Thanks @remonh87 - I will be working on my project back in a few days and will try to test it. |
Happy Holidays to you guys. I have tested this now.
However, after a full flutter clean, in 11.3 regardless of both of these settings being true or false , it will crash upon opening the sheet in release mode so I think there is something that may have yet to be resolved yet. Has anyone else received the same type of results? Thank you. |
Hello,
As the title suggests, this Stripe library does not work on any of my Android phones (for example, the Pixel 6 with Android 14).
Detailed log from the crash in Release build: crash.log
I have tested on multiple phones with Android 10 and Android 14. It always works in Debug mode but crashes instantly in Release mode. Please help.
Also, I have done every single installation step as described here:
https://pub.dev/packages/flutter_stripe
That's the piece of code that shows the payment sheet:
Video from Debug build (works):
https://github.com/user-attachments/assets/ef3eba99-6180-4f5a-8a09-0933f76e5641
Video from Release build (crashes):
https://github.com/user-attachments/assets/bc5daedd-4ef3-4fcf-9116-17815776cddc
This blocks me from releasing the app to production as the payment feature is the core functionality here. The only thing I need for my MVP is to allow customers to pay by card. Nothing else is required at this stage and even this scenario does not work. And I don't want to publish a Debug version to production...
Please help. I have invested lots of time integrating Stripe with my backend but it's not usable end to end as the mobile app (currently my only API client) is not working at all. Thank you.
The text was updated successfully, but these errors were encountered: