dagger: Release build crash using 2.31-alpha
Hi,
My release version runs just fine with 2.30.1-alpha. However, with the new version, the release version fails (at app startup) with this stacktrace:
java.lang.IllegalAccessError: Interface e.b.b.c.c.a$a implemented by class com.peterlaurence.trekme.TrekMeApp_HiltComponents$ActivityC is inaccessible (declaration of 'com.peterlaurence.trekme.TrekMeApp_HiltComponents$ActivityC' appears in base.apk)
at com.peterlaurence.trekme.DaggerTrekMeApp_HiltComponents_SingletonC$ActivityRetainedCImpl.activityComponentBuilder(Unknown Source:0)
at e.b.b.c.d.a.a(Unknown Source:79)
at e.b.b.c.d.a.generatedComponent(Unknown Source:11)
at com.peterlaurence.trekme.Hilt_MainActivity.generatedComponent(Unknown Source:4)
at com.peterlaurence.trekme.Hilt_MainActivity.inject(Unknown Source:7)
at com.peterlaurence.trekme.Hilt_MainActivity.onCreate(Unknown Source:0)
at com.peterlaurence.trekme.MainActivity.onCreate(Unknown Source:0)
at android.app.Activity.performCreate(Activity.java:8000)
at android.app.Activity.performCreate(Activity.java:7984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3404)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7660)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Is there some proguard rule I should add?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 11
- Comments: 19 (3 by maintainers)
Commits related to this issue
- Make Hilt internal entry point and modules public to avoid r8 optimization issues. This CL is a partial rollback of changes made in CL/351213437 when introducing TestInstallIn. Making these classes p... — committed to google/dagger by bcorso 3 years ago
- Revert Hilt internal entry point and modules back to public to avoid r8 optimization issues. This CL is a partial rollback of changes made in CL/351213437 when introducing TestInstallIn. Making these... — committed to google/dagger by bcorso 3 years ago
- Revert Hilt internal entry point and modules back to public to avoid r8 optimization issues. This CL is a partial rollback of changes made in CL/351213437 when introducing TestInstallIn. Making these... — committed to google/dagger by bcorso 3 years ago
@peterLaurence I use a
keepnamesproguard rule !I got a same issue when release build.
Added proguard rules and output logs.
@bcorso : it just the unscramble stack trace, hope it helps. Triggered with version 2.31-alpha. Update to 2.31.2 fix the issue.
Hi, get the same issue. Here is the unscramble stack trace :
@peterLaurence : check this blogpost to unscramble stack trace : https://segunfamisa.com/posts/analyze-stack-trace-in-android-studio
The immediate breakage caused by 2.31 has been reverted and pushed in 2.31.2. I will continue to leave this open though since the general issue still remains.
For anyone who wants the workaround, here is what i added to my proguard/r8 file.
@satoshun thanks for the deobfuscated error message, that helps a lot! @danysantiago was able to reproduce this locally and confirm the issue.
dagger.hilt.android.internal.lifecycle.DefaultViewModelFactories$ActivityEntryPoint, was recently changed from public to pkg-private which is likely what triggered this issue.However, I think the real issue is in r8. Hilt allows non-public entry points by generating a public wrapper for the entry point, e.g.
It sounds like this is a bug in r8 where it is incorrectly removing the wrapper during shrinking/optimization. We should file a bug for r8.
In the meantime, you can try adding a keep rule for all
HiltWrapper_*classes to unblock yourself. We should probably also consider pushing another release that includes this keep rule automatically until the bug is fixed.EDIT: Looks like the keep rule may not be enough… we’ll update once/if we’ve found a general solution. EDIT2: The keep rule does work (just need to force a rebuild in AndroidStudio since it’s not triggered automatically).