Skip to content
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 ProGuard/R8 error #5447

Open
1 of 2 tasks
esl417 opened this issue Feb 18, 2025 · 3 comments
Open
1 of 2 tasks

Android ProGuard/R8 error #5447

esl417 opened this issue Feb 18, 2025 · 3 comments
Assignees

Comments

@esl417
Copy link

esl417 commented Feb 18, 2025

Can we access your project?

  • I give permission for members of the FlutterFlow team to access and test my project for the sole purpose of investigating this issue.

Current Behavior

I am using the Adapty library as my payment processor. I got around the library bug by copying all variables and data types into my app so I can use it myself.

Adapty works for iOS no problem, and several days ago, it was also working for Android. As of today, there is an initialization issue on Android. It seems that during the build configuration ProGuard/R8 are altering the Adapty code in such a way that it prevents initialization. Here is the debug log:

Calling Adapty.identify()...
=== AdaptyError Caught ===
Error Code: 20
Error Message: Adapty was not initialized
Returning: AdaptyErrorStruct
=== ADAPTY DEBUG LOGS ===
Activation error: PlatformException(error, TypeToken must be created with a type argument: new TypeToken<...>() {}; When using code shrinkers (ProGuard, R8, ...) make sure that generic signatures are preserved., null, java.lang.IllegalStateException: TypeToken must be created with a type argument: new TypeToken<...>() {}; When using code shrinkers (ProGuard, R8, ...) make sure that generic signatures are preserved.
at xa.a.b(SourceFile:1)
at xa.a.(SourceFile:1)
at com.adapty.internal.di.Dependencies$init$1$1.(Unknown Source:0)
at com.adapty.internal.di.Dependencies$init$1.invoke(SourceFile:2)
at com.adapty.internal.di.Dependencies$init$1.invoke(SourceFile:1)
at com.adapty.internal.di.DIObject.provide(Unknown Source:26)
at com.adapty.internal.di.Dependencies$init$17.invoke(SourceFile:1)
at com.adapty.internal.di.Dependencies$init$17.invoke(SourceFile:2)
at com.adapty.internal.di.DIObject.provide(Unknown Source:26)
at com.adapty.internal.di.Dependencies$init$15.invoke(SourceFile:1)
at com.adapty.internal.di.Dependencies$init$15.invoke(SourceFile:2)
at com.adapty.internal.di.DIObject.provide(Unknown Source:26)
at com.adapty.internal.di.Dependencies$init$7.invoke(SourceFile:1)
at com.adapty.internal.di.Dependencies$init$7.invoke(SourceFile:2)
at com.adapty.internal.di.DIObject.provide(Unknown Source:26)
at com.adapty.internal.di.Dependencies$init$5.invoke(SourceFile:1)
at com.adapty.internal.di.Dependencies$init$5.invoke(SourceFile:2)
at com.adapty.internal.di.DIObject.provide(Unknown Source:26)
at com.adapty.internal.di.Dependencies$init$47.invoke(SourceFile:1)
at com.adapty.internal.di.Dependencies$init$47.invoke(SourceFile:2)
at com.adapty.internal.di.DIObject.provide(Unknown Source:26)
at com.adapty.internal.di.Dependencies$init$48.invoke(SourceFile:1)
at com.adapty.internal.di.Dependencies$init$48.invoke(SourceFile:2)
at com.adapty.internal.di.DIObject.provide(Unknown Source:26)
at com.adapty.Adapty$special$$inlined$inject$adapty_release$default$1.invoke(Unknown Source:30)
at dd.s.getValue(SourceFile:1)
at com.adapty.Adapty.getAdaptyInternal(Unknown Source:2)
at com.adapty.Adapty.init(Unknown Source:23)
at com.adapty.Adapty.activate(SourceFile:3)
at com.adapty.flutter.AdaptyCallHandler.performActivate(SourceFile:1)
at com.adapty.flutter.AdaptyCallHandler.handleActivate(SourceFile:1)
at com.adapty.flutter.AdaptyCallHandler.onMethodCall(SourceFile:1)
at com.adapty.flutter.AdaptyFlutterPlugin.onMethodCall(SourceFile:1)
at wb.k$a.a(SourceFile:1)
at nb.c.l(SourceFile:1)
at nb.c.m(SourceFile:1)
at nb.c.i(SourceFile:1)
at nb.b.run(SourceFile:1)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:9063)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:588)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
)
[2025-02-18 13:24:53.536790] Starting getProfile call
[2025-02-18 13:24:53.536806] Calling Adapty().getProfile()
[2025-02-18 13:24:53.537813] Adapty error caught: Adapty was not initialized
[2025-02-18 13:24:59.405330] Starting getProfile call
[2025-02-18 13:24:59.405344] Calling Adapty().getProfile()
[2025-02-18 13:24:59.405833] Adapty error caught: Adapty was not initialized

Expected Behavior

Expecting Adapty to initialize as designed so that users can make purchases.

Steps to Reproduce

  1. Have Adapty installed on Android
  2. Open app (this is where the error is, in the background)
  3. Pull up paywall to see error message in UI

Reproducible from Blank

  • The steps to reproduce above start from a blank project.

Bug Report Code (Required)

ITFfksmBw41PsfVY0a6JavpVlWARNjocTeUzlO1hdwwbI+PwEZYcfsnRckttcuqHe1VEBmH+pzgy+cLyjvDPO8E3H0mqQYRTz6ptUxDiRkWmaarWDoeOSXxBM8FWIGLH1ruskxRAPrNpLlYR1ziuF+6+b3qCf9qOYwx5e6fDbOY=

Visual documentation

Image

Environment

- FlutterFlow version: v5.2.1 released February 14, 2025
Flutter version is 3.27.3
- Platform: Android
- Browser name and version:
- Operating system and version affected: Android 14

Additional Information

No response

@esl417 esl417 added the status: needs triage A potential issue that has not been confirmed as a bug. label Feb 18, 2025
@esl417 esl417 changed the title Adapty Android Initialization issue Android ProGuard/R8 error Feb 19, 2025
Copy link
Collaborator

Hello!

There is a solution for this issue, but it requires a manual change in the Android folder. If you're deploying via GitHub or outside of FlutterFlow, you can resolve it by editing the android/app/proguard-rules.pro file and adding the following lines:

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

In the meantime, I’ve reached out to an engineering team member to get further guidance on how to proceed with this issue. I'll update you as soon as I have more information.

Thank you for your patience and understanding!

@esl417
Copy link
Author

esl417 commented Feb 19, 2025 via email

@Alezanello Alezanello self-assigned this Feb 20, 2025
@Alezanello Alezanello removed the status: needs triage A potential issue that has not been confirmed as a bug. label Feb 20, 2025
@esl417
Copy link
Author

esl417 commented Feb 21, 2025

Just as an update, you have to add these rules in the proguard for it to work, the ones above were incomplete:

-keep class com.adapty.** { ; }
-dontwarn com.adapty.ui.
*
-keepattributes Signature
-keep class com.google.gson.reflect.TypeToken { *; }
-keep class * extends com.google.gson.reflect.TypeToken

I am unsure if this is just for the flutterflow version in the Adapty Library, which seems pretty old compared to the most up-to-date version, or all versions of the Adapty SDK.

This does not solve the issue of it deploying from flutterflow though.

Here is the source link: adaptyteam/AdaptySDK-React-Native#117 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants