google/dagger

java.lang.IllegalArgumentException: Multiple entries with same key

devMagics opened this issue · 4 comments

dagger version >=2.51, no issue in version 2.50

this error happen when enable Minify & shrinkResources, icant reach to original property or know how to debug it
the app crashed in first open

buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
}
}

java.lang.IllegalArgumentException: Multiple entries with same key: W5.c=true and W5.c=true
at C7.L.a(SourceFile:45)
at B2.L.i(SourceFile:24)
at Z4.b.a(SourceFile:93)
at com.example.com.ui.screens.activity.Hilt_MainActivity.getDefaultViewModelProviderFactory(SourceFile:15)
at Ta.d.A(SourceFile:23)
at a.a.e(SourceFile:41)
at J5.a.invoke(SourceFile:171)
at h0.b.invoke(SourceFile:7)
at Z.d.a(SourceFile:229)
at ia.a.a(SourceFile:89)
at J5.a.invoke(SourceFile:137)
at h0.b.invoke(SourceFile:7)
at P.I.invoke(SourceFile:195)
at h0.b.invoke(SourceFile:7)
at Z.d.b(SourceFile:152)
at X.q2.a(SourceFile:129)
at J5.a.invoke(SourceFile:103)
at h0.b.invoke(SourceFile:7)
at Z.d.a(SourceFile:229)
at X.e3.a(SourceFile:79)
at A.L.invoke(SourceFile:396)
at h0.b.invoke(SourceFile:7)
at Z.d.b(SourceFile:152)
at X.Q0.h(SourceFile:353)
at i6.d.a(SourceFile:940)
at J5.a.invoke(SourceFile:41)
at h0.b.invoke(SourceFile:7)
at L0.q0.a(SourceFile:57)
at A.E.invoke(SourceFile:949)
at h0.b.invoke(SourceFile:7)
at Z.d.b(SourceFile:152)
at L0.r0.a(SourceFile:399)
at A.s0.invoke(SourceFile:473)
at h0.b.invoke(SourceFile:7)
at Z.d.b(SourceFile:152)
at L0.W.a(SourceFile:621)
at L0.z1.invoke(SourceFile:261)
at h0.b.invoke(SourceFile:7)
at Z.d.a(SourceFile:229)
at L0.z1.invoke(SourceFile:221)
at h0.b.invoke(SourceFile:7)
at Z.d.L(SourceFile:15)
at Z.s.p(SourceFile:203)
at Z.w.k(SourceFile:33)
at Z.q0.a(SourceFile:44)
at Z.w.l(SourceFile:9)
at Z.w.b(SourceFile:3)
at A.b.invoke(SourceFile:605)
at L0.y.setOnViewTreeOwnersAvailable(SourceFile:7)
at L0.A1.b(SourceFile:10)
at L0.A1.onStateChanged(SourceFile:19)
at androidx.lifecycle.x.a(SourceFile:23)
at androidx.lifecycle.y.a(SourceFile:216)
at A.b.invoke(SourceFile:574)
at L0.y.onAttachedToWindow(SourceFile:120)
at android.view.View.dispatchAttachedToWindow(View.java:21980)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3490)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3014)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2465)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9305)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1339)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1348)
at android.view.Choreographer.doCallbacks(Choreographer.java:952)
at android.view.Choreographer.doFrame(Choreographer.java:882)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1322)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

Hi, I suspect this is related to our new feature @LazyClassKey introduced in 2.51, which is used by @HiltViewModel. It might be similar issue to #4309, there is something changed in AGP that resulted in our obfuscation rule fails to function properly. To understand the real cause, there is a map of original class name to the obfuscated class name generated under app/build/ouputs/mapping, which can help you translate the stack trace. Please attach the non-obfuscated stack trace or a repro to help me further debug the issue, thanks!

I've encountered the same issue.
Hilt 2.51.1, AGP 8.2.2.

Adding the proguard rule mentioned in #4309 fixes the problem.

Fyi, a potential fix is in #4331 , it will come with the next release.