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

[Hilt] Release build crash in 2.33-beta #2502

Closed
Kevlin-1 opened this issue Mar 23, 2021 · 9 comments
Closed

[Hilt] Release build crash in 2.33-beta #2502

Kevlin-1 opened this issue Mar 23, 2021 · 9 comments

Comments

@Kevlin-1
Copy link

A few days ago, My release version runs fine with 2.29.1-alpha.
Today, I update the new version, the crash occurred:

java.lang.IllegalAccessError: Interface dagger.hilt.android.internal.lifecycle.HiltViewModelFactory$ActivityCreatorEntryPoint implemented by class com.shenzhen.ukaka.module.app.App_HiltComponents$ActivityC is inaccessible (declaration of 'com.shenzhen.ukaka.module.app.App_HiltComponents$ActivityC' appears in /data/app/com.shenzhen.ukaka-SqpogQviDkVkbAO0RJl8Vg==/base.apk!classes2.dex)
at com.shenzhen.ukaka.module.app.DaggerApp_HiltComponents_SingletonC$ActivityRetainedCImpl.activityComponentBuilder(SourceFile:1)
at dagger.hilt.android.internal.managers.ActivityComponentManager.a(SourceFile:7)
at dagger.hilt.android.internal.managers.ActivityComponentManager.generatedComponent(SourceFile:4)
at com.shenzhen.ukaka.module.login.Hilt_LoginActivity.generatedComponent(SourceFile:1)
at com.shenzhen.ukaka.module.login.Hilt_LoginActivity.o(SourceFile:3)
at com.shenzhen.ukaka.module.login.Hilt_LoginActivity$1.onContextAvailable(SourceFile:1)
at androidx.activity.contextaware.ContextAwareHelper.dispatchOnContextAvailable(SourceFile:3)
at androidx.activity.ComponentActivity.onCreate(SourceFile:2)
at androidx.fragment.app.FragmentActivity.onCreate(SourceFile:1)
at androidx.appcompat.app.AppCompatActivity.onCreate(SourceFile:4)
at com.shenzhen.ukaka.module.base.BaseActivity.onCreate(SourceFile:1)
at android.app.Activity.performCreate(Activity.java:7894)
at android.app.Activity.performCreate(Activity.java:7881)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3283)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
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:2044)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at com.shenzhen.ukaka.util.Cockroach$1.run(SourceFile:1)
at android.os.Handler.handleCallback(Handler.java:914)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7560)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

However, Lowering the version to 2.32 solved the problem

@Kevlin-1 Kevlin-1 changed the title Release build crash in 2.33-beta [Hilt] Release build crash in 2.33-beta Mar 23, 2021
@danysantiago
Copy link
Member

This seems to be the same issue as #2291, which should have been fixed for 2.33-beta. Can you try the workaround mentioned here just to confirm.

@Kevlin-1
Copy link
Author

This seems to be the same issue as #2291, which should have been fixed for 2.33-beta. Can you try the workaround mentioned here just to confirm.

I try to add -keepnames class dagger.hilt.** for proguard rules
Sorry, This doesn't seem to work

@eugene-kirzhanov
Copy link

eugene-kirzhanov commented Apr 8, 2021

Still reproducible in 2.34-beta

Update:
Issue is reproducible when using Hilt v2.33-beta or 2.34-beta with "androidx.hilt:hilt-*:1.0.0-beta01" dependencies.
When switching back androidx dependency to 1.0.0-alpha03 I can use Hilt v2.33-beta and 2.34-beta

I've also tried to add -keepnames class dagger.hilt.** for proguard rules. Nothing changed.

@danysantiago
Copy link
Member

@eugene-kirzhanov, I have not been able to successfully reproduce this. Creating a new 'Basic Navigation' project in Android Studio with Hilt 2.34-beta and androidx.hilt 1.0.0-beta01 along with AGP 4.1.3.

Enabling obfuscation and shinker seems fine too

android {
    // ...
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }

If you could share a repro project that would greatly help us. Maybe you can you share your proguard configuration if its anything different from the default? When building an app there is also a few outputs related to the optimizations located in build/outputs/mapping, if you could share it that could also help us pin-point what is going on with that interface and why R8 is removing it.

@eugene-kirzhanov
Copy link

eugene-kirzhanov commented Apr 9, 2021

@danysantiago Unfortunately, I can't reproduce this issue with basic project, but it still exist in my project that is under NDA.
Proguard configuration contains only "-keep" rules for third-party libraries, nothing special.

I've tried to disable obfuscation (-dontobfuscate and -optimizations !code/allocation/variable) and I've got crash with the following stacktrace:

java.lang.IllegalAccessError: Interface dagger.hilt.android.internal.lifecycle.HiltViewModelFactory$ActivityCreatorEntryPoint implemented by class im.ringl.app.App_HiltComponents$ActivityC is inaccessible (declaration of 'im.ringl.app.App_HiltComponents$ActivityC' appears in /base.apk!classes3.dex)
        at im.ringl.app.DaggerApp_HiltComponents_SingletonC$ActivityRetainedCImpl.activityComponentBuilder(SourceFile:2311)
        at dagger.hilt.android.internal.managers.ActivityComponentManager.createComponent(SourceFile:88)
        at dagger.hilt.android.internal.managers.ActivityComponentManager.generatedComponent(SourceFile:66)
        at im.ringl.app.Hilt_RinglActivity.generatedComponent(SourceFile:41)
        at im.ringl.app.Hilt_RinglActivity.inject(SourceFile:63)
        at im.ringl.app.Hilt_RinglActivity$1.onContextAvailable(SourceFile:34)
        ....

Also I've tried to enable debugging in release build, but I still couldn't find exact place of crash.

However I found a proguard option that allows to start application without crash after adding it to the rules:

-allowaccessmodification

@danysantiago
Copy link
Member

For #2291 we did two things:

During our investigation we also found out that using -allowaccessmodification fixed the issue since it allowed R8 to open up the merged interfaces, but it should not be needed. The R8 team pushed a fix and left some instructions on how to try a version with the fix (see https://issuetracker.google.com/issues/178045782#comment5). Maybe the revert we did in a2798a8 was not enough, so if you could try using version 2.2.51 of R8 without -allowaccessmodification it would help us know if we need to chase this further of if its a matter of a fixed R8 being adopted.

Related question: Which Android Gradle Plugin and Android Build Tools are you using in your project? (It tells us which R8 version is being used).

@eugene-kirzhanov
Copy link

@danysantiago I use Android Gradle Plugin 4.1.3 and Build Tools 30.0.3
R8 version is 2.1.86 (build 8142868c18707f172934d5343ba33dc36cff56ad from go/r8bot (luci-r8-custom-ci-xenial-1-nxk4))

I've just tried to use R8 2.2.51 and 2.2.60 (latest) without -allowaccessmodification and crash is gone.

@Kevlin-1
Copy link
Author

Ok, thx
Use R8 2.2.60 solved this problem

@Kevlin-1 Kevlin-1 reopened this Apr 25, 2021
@danysantiago
Copy link
Member

Closing as new R8 versions fixes this issue.

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