Closed simonbrandhof closed 1 month ago
Hello @simonbrandhof,
Thanks for bringing this issue up.
Flutter's default project creator seems to use old settings. You need to update your project to recent dev tools.
To do this:
Use a new Android Gradle Plugin (AGP) version, the latest stable is 8.5.2.
Configure gradlew
to use at least version 8.7: In android/gradle/wrapper/gradle-wrapper.properties
change to distributionUrl=https\:[//services.gradle.org/distributions/gradle-8.9-bin.zip
When in doubt refer to AGP Documentation.
Update your settings
to use the new Android Gradle Plugin version. In android/settings.gradle
change:
com.android.application
to 8.5.2
Update your settings
to use the new Kotlin version (some of the dependencies on Datatrans SDK require this). In android/settings.gradle
change:
org.jetbrains.kotlin.android
to 1.9.24
This should be enough to run your project with our Datatrans SDK.
Best
Thanks @luiscosta for your great help.
Upgrading AGP and Gradle resolves the issue. Note that the release build failed because of a new obfuscation error:
Caught exception: Already watching path: /home/runner/work/***-app/***-app/android
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /home/runner/work/***-app/***-app/build/app/outputs/mapping/release/missing_rules.txt.
ERROR: R8: Missing class com.google.android.gms.common.api.Status (referenced from: java.lang.Object ch.datatrans.payment.u5.a(int, android.content.Intent, kotlin.coroutines.Continuation))
Missing class com.google.android.gms.tasks.OnCanceledListener (referenced from: java.lang.Object ch.datatrans.payment.K3.invokeSuspend(java.lang.Object))
Missing class com.google.android.gms.tasks.OnFailureListener (referenced from: java.lang.Object ch.datatrans.payment.K3.invokeSuspend(java.lang.Object))
Missing class com.google.android.gms.tasks.OnSuccessListener (referenced from: java.lang.Object ch.datatrans.payment.K3.invokeSuspend(java.lang.Object))
Missing class com.google.android.gms.tasks.Task (referenced from: java.lang.Object ch.datatrans.payment.K3.invokeSuspend(java.lang.Object) and 2 other contexts)
Missing class com.google.android.gms.tasks.Tasks (referenced from: java.lang.Object ch.datatrans.payment.S4.invokeSuspend(java.lang.Object))
Missing class com.google.android.gms.wallet.AutoResolveHelper (referenced from: java.lang.Object ch.datatrans.payment.a5.invoke(java.lang.Object) and 1 other context)
Missing class com.google.android.gms.wallet.CreditCardExpirationDate (referenced from: void ch.datatrans.payment.L3.b(ch.datatrans.payment.L3, androidx.activity.result.ActivityResult))
Missing class com.google.android.gms.wallet.IsReadyToPayRequest (referenced from: java.lang.Object ch.datatrans.payment.S4.invokeSuspend(java.lang.Object))
Missing class com.google.android.gms.wallet.PaymentCardRecognitionIntentRequest (referenced from: com.google.android.gms.wallet.PaymentCardRecognitionIntentRequest ch.datatrans.payment.K3.c and 6 other contexts)
Missing class com.google.android.gms.wallet.PaymentCardRecognitionIntentResponse (referenced from: java.lang.Object ch.datatrans.payment.J3.invoke(java.lang.Object))
Missing class com.google.android.gms.wallet.PaymentCardRecognitionResult (referenced from: void ch.datatrans.payment.L3.b(ch.datatrans.payment.L3, androidx.activity.result.ActivityResult))
Missing class com.google.android.gms.wallet.PaymentData (referenced from: java.lang.Object ch.datatrans.payment.u5.a(int, android.content.Intent, kotlin.coroutines.Continuation))
Missing class com.google.android.gms.wallet.PaymentDataRequest (referenced from: java.lang.Object ch.datatrans.payment.a5.invoke(java.lang.Object) and 1 other context)
Missing class com.google.android.gms.wallet.PaymentsClient (referenced from: java.lang.Object ch.datatrans.payment.K3.invokeSuspend(java.lang.Object) and 2 other contexts)
Missing class com.google.android.gms.wallet.Wallet$WalletOptions$Builder (referenced from: java.lang.Object ch.datatrans.payment.K3.invokeSuspend(java.lang.Object) and 2 other contexts)
Missing class com.google.android.gms.wallet.Wallet$WalletOptions (referenced from: java.lang.Object ch.datatrans.payment.K3.invokeSuspend(java.lang.Object) and 2 other contexts)
Missing class com.google.android.gms.wallet.Wallet (referenced from: java.lang.Object ch.datatrans.payment.K3.invokeSuspend(java.lang.Object) and 3 other contexts)
Missing class com.klarna.mobile.sdk.api.KlarnaLoggingLevel (referenced from: void ch.datatrans.payment.v6.onCreate(android.os.Bundle))
Missing class com.klarna.mobile.sdk.api.KlarnaMobileSDKCommon$Companion (referenced from: void ch.datatrans.payment.v6.onCreate(android.os.Bundle))
Missing class com.klarna.mobile.sdk.api.KlarnaMobileSDKCommon (referenced from: void ch.datatrans.payment.v6.onCreate(android.os.Bundle))
Missing class com.klarna.mobile.sdk.api.payments.KlarnaPaymentView (referenced from: com.klarna.mobile.sdk.api.payments.KlarnaPaymentView ch.datatrans.payment.v6.d and 4 other contexts)
Missing class com.klarna.mobile.sdk.api.payments.KlarnaPaymentViewCallback (referenced from: java.lang.Object ch.datatrans.payment.l6.invoke(java.lang.Object) and 1 other context)
Missing class com.samsung.android.sdk.samsungpay.v2.PartnerInfo (referenced from: java.lang.Object ch.datatrans.payment.Ea.a(kotlin.coroutines.Continuation) and 2 other contexts)
Missing class com.samsung.android.sdk.samsungpay.v2.SamsungPay (referenced from: java.lang.Object ch.datatrans.payment.Ea.a(kotlin.coroutines.Continuation) and 1 other context)
Missing class com.samsung.android.sdk.samsungpay.v2.SpaySdk$Brand (referenced from: java.util.List ch.datatrans.payment.paymentmethods.SamsungPayConfig.getCardBrands$lib_release(java.util.List))
Missing class com.samsung.android.sdk.samsungpay.v2.SpaySdk$ServiceType (referenced from: com.samsung.android.sdk.samsungpay.v2.PartnerInfo ch.datatrans.payment.paymentmethods.SamsungPayConfig.createPartnerInfo$lib_release(boolean))
Missing class com.samsung.android.sdk.samsungpay.v2.StatusListener (referenced from: java.lang.Object ch.datatrans.payment.Ea.a(kotlin.coroutines.Continuation) and 1 other context)
Missing class com.samsung.android.sdk.samsungpay.v2.payment.CustomSheetPaymentInfo$AddressInPaymentSheet (referenced from: void ch.datatrans.payment.gb.<init>(ch.datatrans.payment.jc))
Missing class com.samsung.android.sdk.samsungpay.v2.payment.CustomSheetPaymentInfo$Builder (referenced from: void ch.datatrans.payment.gb.<init>(ch.datatrans.payment.jc))
Missing class com.samsung.android.sdk.samsungpay.v2.payment.CustomSheetPaymentInfo$PaymentProtocol (referenced from: void ch.datatrans.payment.gb.<init>(ch.datatrans.payment.jc))
Missing class com.samsung.android.sdk.samsungpay.v2.payment.CustomSheetPaymentInfo (referenced from: java.lang.Object ch.datatrans.payment.Ra.invoke(java.lang.Object) and 1 other context)
Missing class com.samsung.android.sdk.samsungpay.v2.payment.PaymentManager$CustomSheetTransactionInfoListener (referenced from: java.lang.Object ch.datatrans.payment.Ra.invoke(java.lang.Object) and 1 other context)
Missing class com.samsung.android.sdk.samsungpay.v2.payment.PaymentManager (referenced from: com.samsung.android.sdk.samsungpay.v2.payment.PaymentManager ch.datatrans.payment.Qa.b and 2 other contexts)
Missing class com.samsung.android.sdk.samsungpay.v2.payment.sheet.AmountBoxControl (referenced from: void ch.datatrans.payment.gb.<init>(ch.datatrans.payment.jc))
Missing class com.samsung.android.sdk.samsungpay.v2.payment.sheet.CustomSheet (referenced from: void ch.datatrans.payment.gb.<init>(ch.datatrans.payment.jc))
Missing class com.samsung.android.sdk.samsungpay.v2.payment.sheet.SheetControl (referenced from: void ch.datatrans.payment.gb.<init>(ch.datatrans.payment.jc))
Missing class lib.android.paypal.com.magnessdk.Environment (referenced from: java.lang.String ch.datatrans.payment.h9.a(android.content.Context, java.lang.String))
Missing class lib.android.paypal.com.magnessdk.InvalidInputException (referenced from: java.lang.String ch.datatrans.payment.h9.a(android.content.Context, java.lang.String))
Missing class lib.android.paypal.com.magnessdk.MagnesResult (referenced from: java.lang.String ch.datatrans.payment.h9.a(android.content.Context, java.lang.String))
Missing class lib.android.paypal.com.magnessdk.MagnesSDK (referenced from: java.lang.Object ch.datatrans.payment.W7.invoke() and 1 other context)
Missing class lib.android.paypal.com.magnessdk.MagnesSettings$Builder (referenced from: java.lang.String ch.datatrans.payment.h9.a(android.content.Context, java.lang.String))
Missing class lib.android.paypal.com.magnessdk.MagnesSettings (referenced from: java.lang.String ch.datatrans.payment.h9.a(android.content.Context, java.lang.String))
Missing class lib.android.paypal.com.magnessdk.MagnesSource (referenced from: java.lang.String ch.datatrans.payment.h9.a(android.content.Context, java.lang.String))
FAILURE: Build failed with an exception.
For information that was resolved by adding proguard rules (stackoverflow):
android/app/proguard-rules.pro
and copy the content of the generated file build/app/outputs/mapping/release/missing_rules.txt
android
of the file android/app/build.gradle
with:
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
@simonbrandhof Thanks for the heads-up on the release build!
Build fails with the following error when upgrading
ch.datatrans:android-sdk
from3.6.1
to3.7.0
on a fresh empty Android project:Could the root cause be the way the SDK is obfuscated? I didn't find any trick to resolve this issue yet.
Steps to reproduce
flutter create helloworld
android/build.gradle
:android/app/build.gradle
:flutter build appbundle --debug
Error in verbose mode