AdaptySDK-Flutter icon indicating copy to clipboard operation
AdaptySDK-Flutter copied to clipboard

Adapty not activating successfully

Open PetrKubes97 opened this issue 1 year ago • 10 comments
trafficstars

Hi, after updating to flutter 3.24.1 and adapty_flutter 2.10.2, I've started getting the following issue.

Adapty().activate() runs successfully, but all subsequent calls fails:

I/flutter ( 5697): [AdaptyFlutter v2.10.2] - VERBOSE: --> Adapty.identify() I/flutter ( 5697): [AdaptyFlutter v2.10.2] - VERBOSE: <-- Adapty.identify() Adapty Error (code: 20, message: Adapty was not initialized, detail: null)

Paywalls can't be retrieved either.

I haven't tried it with other projects yet, but it works in debug mode and does not in release mode (apk). I haven't tried app bundles yet.

Any ideas?

PetrKubes97 avatar Aug 28 '24 08:08 PetrKubes97

Hi @PetrKubes97

but it works in debug mode and does not in release mode

usually it's related to obfuscation issues

could you please try adding the following to your proguard config file? -keep class com.adapty.** { *; }

vladd-g avatar Aug 28 '24 08:08 vladd-g

Hi, unfortunately does not seem to work.

buildTypes {
        release {
            signingConfig signingConfigs.release
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
        }
    }

proguard-rules.pro:

-keep class com.adapty.** { *; }

PetrKubes97 avatar Aug 28 '24 09:08 PetrKubes97

I'm thinking, is it necessary to have a certain version of gradle? I'm still using the Flutter default 7.x + declarative build.gradle https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply.

PetrKubes97 avatar Aug 28 '24 09:08 PetrKubes97

could you please try upgrading? as here

vladd-g avatar Aug 28 '24 09:08 vladd-g

I've had troubles with other libraries not being compatible with that.

PetrKubes97 avatar Aug 28 '24 09:08 PetrKubes97

what are those errors?

and, as a workaround, you can try reverting those changes locally, in ~/.pub-cache/hosted/pub.dev/adapty_flutter-2.10.2/android/build.gradle

vladd-g avatar Aug 28 '24 09:08 vladd-g

Not sure. I remember some problems with R8. I'll test it more in the evening. Either way, I think the SDK should work with the default flutter settings, but it might just be my project.

PetrKubes97 avatar Aug 28 '24 10:08 PetrKubes97

Hi, after updating to flutter 3.24.1 and adapty_flutter 2.10.2, I've started getting the following issue.

Adapty().activate() runs successfully, but all subsequent calls fails:

I/flutter ( 5697): [AdaptyFlutter v2.10.2] - VERBOSE: --> Adapty.identify() I/flutter ( 5697): [AdaptyFlutter v2.10.2] - VERBOSE: <-- Adapty.identify() Adapty Error (code: 20, message: Adapty was not initialized, detail: null)

Paywalls can't be retrieved either.

I haven't tried it with other projects yet, but it works in debug mode and does not in release mode (apk). I haven't tried app bundles yet.

Any ideas?

I'm having a similar issue, my stack does lock a little differently though. I've tried the above suggestions but they didn't solve the issue. Works fine in debug but fails in release. EDIT: fails for AAB as well, which is a mayor problem

I/flutter (  847): [AdaptyFlutter v2.10.2] - VERBOSE: --> Adapty.set_log_level()
I/flutter (  847): [AdaptyFlutter v2.10.2] - VERBOSE: <-- Adapty.set_log_level()
I/flutter (  847): [AdaptyFlutter v2.10.2] - VERBOSE: --> Adapty.get_profile()
I/flutter (  847): [AdaptyFlutter v2.10.2] - VERBOSE: <-- Adapty.get_profile() Adapty Error (code: 20, message: Adapty was not initialized, detail: null)
E/flutter (  847): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: (code: 20, message: Adapty was not initialized, detail: null)
E/flutter (  847): #0      Adapty._invokeMethodHandlingErrors (package:adapty_flutter/src/adapty.dart:301)
E/flutter (  847): <asynchronous suspension>
E/flutter (  847): #1      Adapty.getProfile (package:adapty_flutter/src/adapty.dart:59)
E/flutter (  847): <asynchronous suspension>
E/flutter (  847): #2      AdaptyServices.checkSubscriptionStatus (package:bmi_calculator/services/monetization_services/adapty_services.dart:133)
E/flutter (  847): <asynchronous suspension>
E/flutter (  847): #3      main (package:bmi_calculator/main.dart:27)
E/flutter (  847): <asynchronous suspension>
E/flutter (  847): 

HarmonyV avatar Sep 25 '24 12:09 HarmonyV

Could you please try v2.10.3?

vladd-g avatar Sep 26 '24 14:09 vladd-g

Update:

so apparently in my case, the issue occurred because I updated my Gradle version to 8.3 (also tried 8.4). Which I find extremely odd. After reverting back to gradle 7.6.3 adapty works as intended.

HarmonyV avatar Sep 27 '24 11:09 HarmonyV

`You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply

You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply

ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/julianbaumann/Development/App-Learning/learning-application/build/app/outputs/mapping/simplecryptoprodRelease/missing_rules.txt. ERROR: R8: Missing class com.adapty.ui.AdaptyUI$Action$Close (referenced from: void com.adapty.internal.crossplatform.AdaptyUIActionTypeAdapterFactory$create$result$1.write(com.google.gson.stream.JsonWriter, com.adapty.ui.AdaptyUI$Action)) Missing class com.adapty.ui.AdaptyUI$Action$Custom (referenced from: void com.adapty.internal.crossplatform.AdaptyUIActionTypeAdapterFactory$create$result$1.write(com.google.gson.stream.JsonWriter, com.adapty.ui.AdaptyUI$Action)) Missing class com.adapty.ui.AdaptyUI$Action$OpenUrl (referenced from: void com.adapty.internal.crossplatform.AdaptyUIActionTypeAdapterFactory$create$result$1.write(com.google.gson.stream.JsonWriter, com.adapty.ui.AdaptyUI$Action)) Missing class com.adapty.ui.AdaptyUI$Action (referenced from: com.adapty.ui.AdaptyUI$Action com.adapty.internal.crossplatform.AdaptyUIActionTypeAdapterFactory$create$result$1.read(com.google.gson.stream.JsonReader) and 3 other contexts)

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:minifySimplecryptoprodReleaseWithR8'.

A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable Compilation failed to complete

  • 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 42s Running Gradle task 'bundleSimplecryptoprodRelease'... 42,9s Gradle task bundleSimplecryptoprodRelease failed with exit code 1`

Is this issue also related to Adapty and Gradle update? I get this after I have upgraded Gradle to 8.3.

LoadJulz avatar Oct 02 '24 15:10 LoadJulz

@LoadJulz replied here

vladd-g avatar Oct 06 '24 09:10 vladd-g

FWIW i could solve the problem on android - at least in debug mode - with the help of support:

pass the api key to activation like this: Adapty().activate(apiKey: key);

no need to roll back to gradle 7.x; my setup: flutter 3.24.4, gradle 8.3, java 17

tomquas avatar Oct 31 '24 09:10 tomquas

you can also try disabling fullMode as shown in the snippet here

vladd-g avatar Oct 31 '24 10:10 vladd-g