Skip to content

Fix for java.lang.IllegalAccessError: Interface androidx.lifecycle.c #547

Merged
vegaro merged 1 commit into
mainfrom
fix-proguard-lifecycle
Dec 13, 2022
Merged

Fix for java.lang.IllegalAccessError: Interface androidx.lifecycle.c #547
vegaro merged 1 commit into
mainfrom
fix-proguard-lifecycle

Conversation

@vegaro

@vegaro vegaro commented Dec 13, 2022

Copy link
Copy Markdown
Member

Makes sure androidx.lifecycle.DefaultLifecycleObserver doesn't get stripped out by R8.

We got reports of this in https://play.google.com/sdk-console/u/1/accounts/3894912036640479868/sdks/8672516042485634097/crashes/347b470a/details?timeRange=LAST_28_DAYS&installSources=PLAY_STORE&crashStatus=SDK_CRASH_STATUS_UNSPECIFIED and also via support. The stacktrace looks like:

Exception java.lang.IllegalAccessError: Interface androidx.lifecycle.c implemented by class com.revenuecat.purchases.AppLifecycleHandler is inaccessible (declaration of 'com.revenuecat.purchases.AppLifecycleHandler' appears in base.apk)
  at com.revenuecat.purchases.Purchases$lifecycleHandler$2.invoke (Purchases.java)
  at com.revenuecat.purchases.Purchases$lifecycleHandler$2.invoke (Purchases.java)
  at kotlin.SynchronizedLazyImpl.getValue (SynchronizedLazyImpl.java)
  at com.revenuecat.purchases.Purchases.getLifecycleHandler (Purchases.java)
  at com.revenuecat.purchases.Purchases.access$getLifecycleHandler (Purchases.java)
  at com.revenuecat.purchases.Purchases$1.invoke (Purchases.java)
  at com.revenuecat.purchases.Purchases$1.invoke (Purchases.java)
  at com.revenuecat.purchases.Purchases.dispatch (Purchases.java)
  at com.revenuecat.purchases.Purchases.<init> (Purchases.java)
  at com.revenuecat.purchases.Purchases.<init> (Purchases.java)
  at com.revenuecat.purchases.PurchasesFactory.createPurchases (PurchasesFactory.java)
  at com.revenuecat.purchases.Purchases$Companion.configure (Purchases.java)
  at com.revenuecat.purchases.hybridcommon.CommonKt.configure (CommonKt.java)
  at com.revenuecat.purchases.hybridcommon.CommonKt.configure$default (CommonKt.java)
  at com.revenuecat.purchases.hybridcommon.CommonKt.configure (CommonKt.java)
  at <private>
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:236)
  at android.app.ActivityThread.main (ActivityThread.java:8087)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:620)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1011)

I found reports of this in:

I will port this change all the way down to purchases-android, but I would like to ship it first for Flutter since I think most affected apps will be Flutter.

I built a Flutter app on release mode and it looks like the class is there after this change:

Screenshot 2022-12-13 at 7 38 07 PM

I can't see the class when analyzing the apk before this change, but I am not sure if it's due to it being renamed or something.

I wasn't able to reproduce the stacktrace, but I am pretty optimistic this will fix it.

@vegaro vegaro added the pr:fix A bug fix label Dec 13, 2022
@vegaro vegaro requested a review from a team December 13, 2022 18:42

@NachoSoto NachoSoto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👍🏻

@tonidero

Copy link
Copy Markdown
Contributor

Hmm R8/Proguard shouldn't remove a class when it's being used, but it should obfuscate it. Honestly I'm not sure why obfuscating it would cause this error... But the link you posted about the issue in the flutter plugins repo seems to be the same and that seems to have fixed it, so maybe it's an issue in R8 as they posted... Anyway, I think this is ok 👍

Jethro87 pushed a commit to Jethro87/purchases-flutter that referenced this pull request Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants