android / nowinandroid

A fully functional Android app built entirely with Kotlin and Jetpack Compose
Apache License 2.0
16.51k stars 2.97k forks source link

[Bug]: Nia will be crash if I package it to a demo release apk to install on phone, because I replace my own code or delete the code in setContent #1619

Open lcpp-nt opened 4 hours ago

lcpp-nt commented 4 hours ago

Is there an existing issue for this?

Is there a StackOverflow question about this issue?

What happened?

【Bug】I conducted the following tests: 1) Directly package the original project as. apk and install it on the phone --->will not crash 2) Delete the following code and then perform operation 1->apk crashes! delete this code : MainActivity/onCreate/CompositionLocalProvider( LocalAnalyticsHelper provides analyticsHelper, LocalTimeZone provides currentTimeZone, ) { ... }

Why is that? If I try to replace setContent{xxx} with my own Compose function,then package it as a demo release apk to install on my phone,it will be crash !

I has no this proplem on the version 0.1.2 of Nia.

Relevant logcat output

java.lang.IllegalArgumentException: Multiple entries with same key: C4.d=true and C4.d=true
    at W2.f.a(SourceFile:85)
    at C0.d.b(SourceFile:24)
    at com.google.samples.apps.nowinandroid.MainActivity.j(SourceFile:64)
    at H0.e.getValue(SourceFile:23)
    at h4.i.o(SourceFile:31)
    at h4.i.h(SourceFile:13)
    at androidx.lifecycle.K.o(SourceFile:33)
    at androidx.lifecycle.K.h(SourceFile:13)
    at a6.k.x(SourceFile:5)
    at B5.U.d(SourceFile:10)
    at androidx.lifecycle.L.o(SourceFile:72)
    at k5.a.r(SourceFile:9)
    at H5.a.f(SourceFile:124)
    at B5.a.h0(SourceFile:99)
    at B5.U.h(SourceFile:36)
    at androidx.lifecycle.M.f(SourceFile:20)
    at androidx.lifecycle.w.a(SourceFile:23)
    at androidx.lifecycle.x.h(SourceFile:330)
    at androidx.lifecycle.x.e(SourceFile:77)
    at androidx.lifecycle.x.d(SourceFile:15)
    at androidx.lifecycle.e0.b(SourceFile:25)
    at androidx.lifecycle.Q.onActivityPostStarted(SourceFile:10)
    at android.app.Activity.dispatchActivityPostStarted(Activity.java:1494)
    at android.app.Activity.performStart(Activity.java:8589)
    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3850)
    at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
    at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2389)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:210)
    at android.os.Looper.loop(Looper.java:299)
    at android.app.ActivityThread.main(ActivityThread.java:8261)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:559)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)
    Suppressed: H5.e: [r0{Cancelling}@e61fbd5, Dispatchers.Main.immediate]

Code of Conduct

lcpp-nt commented 2 hours ago

It seems to be the same issue as #1569. I compared the mapping file and found that there are two ViewModel=true.But this is just my guess now!