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

java.lang.IllegalArgumentException: Multiple entries with same key #4323

Closed
devMagics opened this issue Jun 6, 2024 · 17 comments
Closed

java.lang.IllegalArgumentException: Multiple entries with same key #4323

devMagics opened this issue Jun 6, 2024 · 17 comments

Comments

@devMagics
Copy link

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)

@wanyingd1996
Copy link

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!

@KarolKsionek
Copy link

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

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

@wanyingd1996
Copy link

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

@burntcookie90
Copy link

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

Do you know when we'll see this release?

@bcorso
Copy link

bcorso commented Aug 5, 2024

I'll try to get a release out today. I'm closing this for now, but please report back if you still see issues.

Also, in the future you can feel free to test out fixes before they are released using the HEAD-SNAPSHOT versions.

@bcorso bcorso closed this as completed Aug 5, 2024
@devMagics
Copy link
Author

after update to version 2.52 the issue not fixed so i returned back to 2.50

@bcorso bcorso reopened this Aug 6, 2024
@bcorso
Copy link

bcorso commented Aug 6, 2024

@devMagics Thanks for the update. If you can get a deobfuscated stacktrace it may help narrow down the issue.

@devMagics
Copy link
Author

how to reach a deobfuscated stacktrace?

@wanyingd1996
Copy link

how to reach a deobfuscated stacktrace?

Either apply -dontobfuscate rule in your proguard file or if you build with gradle, 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

@devMagics
Copy link
Author

devMagics commented Aug 6, 2024

if i add -dontobfuscate in progaurd no issue found, after remove it and build signed app i get same issue
i already check the mapping path but not found F5.f prop in any file , can you guide me which file and details you need me to copy here.
find below the issue

java.lang.IllegalArgumentException: Multiple entries with same key: F5.f=true and F5.f=true
     at t6.L.a(SourceFile:45)
     at B0.C.g(SourceFile:433)
     at T4.a.a(SourceFile:91)
     at
 com.examples.ui.screens.activity.Hilt_MainActivity.getDefaultViewModelProviderFactory(SourceFile:15)
at d4.t.w(SourceFile:23)
at l4.f.h(SourceFile:38)
at s5.a.invoke(SourceFile:109)
at e0.c.invoke(SourceFile:7)
at W.d.a(SourceFile:229)
at d4.m.b(SourceFile:39)
at s5.a.invoke(SourceFile:75)
at e0.c.invoke(SourceFile:7)
at W.d.a(SourceFile:229)
at V3.Y0.a(SourceFile:79)
at B3.l.invoke(SourceFile:361)
at e0.c.invoke(SourceFile:7)
at W.d.b(SourceFile:152)
at N9.d.g(SourceFile:1131)
at U5.e.a(SourceFile:247)
at s5.a.invoke(SourceFile:41)
at e0.c.invoke(SourceFile:7)
at I0.k0.a(SourceFile:72)
at C.h0.invoke(SourceFile:893)
at e0.c.invoke(SourceFile:7)
at W.d.b(SourceFile:152)
at I0.l0.a(SourceFile:399)
at E.g.invoke(SourceFile:152)
at e0.c.invoke(SourceFile:7)
at W.d.b(SourceFile:152)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.a(SourceFile:622)
at I0.r1.invoke(SourceFile:261)
at e0.c.invoke(SourceFile:7)
at W.d.a(SourceFile:229)
at I0.r1.invoke(SourceFile:221)
at e0.c.invoke(SourceFile:7)
at W.d.K(SourceFile:15)
at W.r.p(SourceFile:203)
at W.v.k(SourceFile:32)
at W.r0.a(SourceFile:44)
at W.v.l(SourceFile:9)
at W.v.f(SourceFile:3)
at A3.s.invoke(SourceFile:873)
at I0.u.setOnViewTreeOwnersAvailable(SourceFile:7)
at I0.s1.f(SourceFile:10)
at I0.s1.onStateChanged(SourceFile:19)
at androidx.lifecycle.x.a(SourceFile:23)
at androidx.lifecycle.y.a(SourceFile:216)
at A3.s.invoke(SourceFile:842)
at I0.u.onAttachedToWindow(SourceFile:120)
at android.view.View.dispatchAttachedToWindow(View.java:21980)
                                                                                                    	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3493)
                                                                                                    	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3500)
                                                                                                    	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3500)
                                                                                                    	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3500)
                                                                                                    	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3500)
                                                                                                    	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)

@bcorso
Copy link

bcorso commented Aug 6, 2024

i already check the mapping path but not found F5.f prop in any file

It would be helpful to know F5.f at the very least. If it's not in the mapping file then that seems wrong. Since deobfuscating R8 is not our expertise, I would suggest looking elsewhere (e.g. StackOverflow) to get help with this and posting back once you're able to deobfuscate.

@danysantiago
Copy link
Member

how to reach a deobfuscated stacktrace?

Instructions for de-obsufcating and debugging R8 can be found at https://developer.android.com/build/shrink-code#retracing

@ecoin-finance
Copy link

This issue still not fixed with hilt 2.52.

Hilt 2.52, AGP 8.6.0.

For those who is facing this issue, add this on the pro-guard-rules

-keepclasseswithmembers,includedescriptorclasses class * {
   @dagger.internal.KeepFieldType <fields>;
}

Will fix for sure!

@MiSikora
Copy link

MiSikora commented Sep 2, 2024

I'm experiencing the same. Here's the stack trace:

java.lang.RuntimeException: Unable to resume activity {au.com.shiftyjelly.pocketcasts/au.com.shiftyjelly.pocketcasts.wear.MainActivity}: java.lang.IllegalArgumentException: Multiple entries with same key: U6.b=true and U6.b=true
	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4799)
	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4832)
	at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
	at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2304)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7894)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.IllegalArgumentException: Multiple entries with same key: U6.b=true and U6.b=true
	at com.google.common.collect.ImmutableMap$Builder$DuplicateKey.exception(ImmutableMap.java:703)
	at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:591)
	at com.google.common.collect.ImmutableMap$Builder.buildOrThrow(ImmutableMap.java:621)
	at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:608)
	at au.com.shiftyjelly.pocketcasts.wear.DaggerPocketCastsWearApplication_HiltComponents_SingletonC$ActivityCImpl.getViewModelKeys(DaggerPocketCastsWearApplication_HiltComponents_SingletonC.java:2579)
	at au.com.shiftyjelly.pocketcasts.wear.DaggerPocketCastsWearApplication_HiltComponents_SingletonC$ActivityCImpl.getHiltInternalFactoryFactory(DaggerPocketCastsWearApplication_HiltComponents_SingletonC.java:2574)
	at dagger.hilt.android.internal.lifecycle.DefaultViewModelFactories.getActivityFactory(DefaultViewModelFactories.java:53)
	at au.com.shiftyjelly.pocketcasts.wear.Hilt_MainActivity.getDefaultViewModelProviderFactory(Hilt_MainActivity.java:105)
	at au.com.shiftyjelly.pocketcasts.wear.MainActivity$special$$inlined$viewModels$default$1.invoke(MainActivity.java:80)
	at au.com.shiftyjelly.pocketcasts.wear.MainActivity$special$$inlined$viewModels$default$1.invoke(MainActivity.java:79)
	at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.java:48)
	at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.java:35)
	at au.com.shiftyjelly.pocketcasts.wear.MainActivity.getViewModel(MainActivity.kt:67)
	at au.com.shiftyjelly.pocketcasts.wear.MainActivity.onResume(MainActivity.kt:90)
	at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1531)
	at android.app.Activity.performResume(Activity.java:8422)
	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4789)
	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4832)
	at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
	at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2304)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7894)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

And U6.b is au.com.shiftyjelly.pocketcasts.search.searchhistory.SearchHistoryViewModel -> U6.b

I can confirm that both disabling obfuscation or this config work.

@argenkiwi
Copy link

Has this issue been confirmed? Can we expect it to be fixed in the upcoming release?

@wanyingd1996
Copy link

Hi, we are working on a potential fix. At the meantime, can you try include

-keepclasseswithmembers,includedescriptorclasses, allowobfuscation class * {
   @dagger.internal.KeepFieldType <fields>;
}

in the proguard rule and see if it helps? We are suspecting the shrinking rule is causing the class still being merged even though we used the keep rule. Thanks

@Charityy46
Copy link

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)

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

Successfully merging a pull request may close this issue.

10 participants