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: Key xxx:transition was used multiple times on kotlin 2.0.0-RC2 & r8 #411

Closed
qdsfdhvh opened this issue May 12, 2024 · 3 comments · Fixed by #412

Comments

@qdsfdhvh
Copy link
Contributor

qdsfdhvh commented May 12, 2024

demo: https://github.com/qdsfdhvh/voyager-crash-of-kotlin2

same crash with #410, but i am using kotlin 2.0.0-RC2 and open r8:

Like demo, my home is object HomeScreen, when i open a object DetailScreen, app will be crash this error, but fine with data object DetailScreen;

and if my home is data object HomeScreen, open object DetailScreen is fine, but then open another object XXXScreen, app also crash.

I'm still working on the exact reason for this as well, currently my workaround is replace all object XXScreen to data object XXScreen.

@qdsfdhvh
Copy link
Contributor Author

I seem to have found the reason that Screen.key was optimised out, I added the following configuration and it solved it.

-keepclassmembers class * implements cafe.adriel.voyager.core.screen.Screen {
    public getKey();
}

Maybe add it to the library's consumer-rules.pro?

@qdsfdhvh
Copy link
Contributor Author

qdsfdhvh commented May 12, 2024

I used diffuse to compare the differences between the apk's:

OLD: app-debug.apk (signature: V2)
NEW: app-debug-fix.apk (signature: V2)

          │           compressed           │         uncompressed         
          ├───────────┬───────────┬────────┼──────────┬──────────┬────────
 APK      │ old       │ new       │ diff   │ old      │ new      │ diff   
──────────┼───────────┼───────────┼────────┼──────────┼──────────┼────────
      dex │ 604.7 KiB │ 604.5 KiB │ -147 B │  1.2 MiB │  1.2 MiB │  +96 B 
     arsc │  74.3 KiB │  74.3 KiB │    0 B │ 74.2 KiB │ 74.2 KiB │    0 B 
 manifest │   1.8 KiB │   1.8 KiB │    0 B │  5.7 KiB │  5.7 KiB │    0 B 
      res │  36.8 KiB │  36.8 KiB │   -4 B │ 41.8 KiB │ 41.8 KiB │    0 B 
    asset │   3.3 KiB │   3.3 KiB │   +3 B │  3.1 KiB │  3.1 KiB │   +7 B 
    other │    22 KiB │    22 KiB │    0 B │ 32.1 KiB │ 32.1 KiB │    0 B 
──────────┼───────────┼───────────┼────────┼──────────┼──────────┼────────
    total │ 742.8 KiB │ 742.7 KiB │ -148 B │  1.4 MiB │  1.4 MiB │ +103 B 

 DEX     │ old  │ new  │ diff       
─────────┼──────┼──────┼────────────
   files │    1 │    1 │  0         
 strings │ 6692 │ 6693 │ +1 (+2 -1) 
   types │ 2294 │ 2295 │ +1 (+1 -0) 
 classes │ 1759 │ 1760 │ +1 (+1 -0) 
 methods │ 9706 │ 9708 │ +2 (+3 -1) 
  fields │ 5191 │ 5190 │ -1 (+2 -3) 

 ARSC    │ old │ new │ diff 
─────────┼─────┼─────┼──────
 configs │  97 │  97 │  0   
 entries │ 123 │ 123 │  0   

=================
====   APK   ====
=================

     compressed     │   uncompressed   │                                
───────────┬────────┼─────────┬────────┤                                
 size      │ diff   │ size    │ diff   │ path                           
───────────┼────────┼─────────┼────────┼────────────────────────────────
 604.5 KiB │ -147 B │ 1.2 MiB │  +96 B │ ∆ classes.dex                  
   2.8 KiB │   +6 B │ 2.7 KiB │   +6 B │ ∆ assets/dexopt/baseline.prof  
   7.7 KiB │   -4 B │ 7.6 KiB │    0 B │ ∆ res/-6.webp                  
     486 B │   -3 B │   354 B │   +1 B │ ∆ assets/dexopt/baseline.profm 
───────────┼────────┼─────────┼────────┼────────────────────────────────
 615.6 KiB │ -148 B │ 1.2 MiB │ +103 B │ (total)                        


=================
====   DEX   ====
=================

STRINGS:

   old  │ new  │ diff       
  ──────┼──────┼────────────
   6692 │ 6693 │ +1 (+2 -1) 
  
  + Le1/i;
  + ~~R8{"backend":"dex","compilation-mode":"release","has-checksums":false,"min-api":24,"pg-map-id":"79a64e1","r8-mode":"full","version":"8.4.22"}
  
  - ~~R8{"backend":"dex","compilation-mode":"release","has-checksums":false,"min-api":24,"pg-map-id":"cc45031","r8-mode":"full","version":"8.4.22"}
  

TYPES:

   old  │ new  │ diff       
  ──────┼──────┼────────────
   2294 │ 2295 │ +1 (+1 -0) 
  
  + Le1/i;
  

METHODS:

   old  │ new  │ diff       
  ──────┼──────┼────────────
   9706 │ 9708 │ +2 (+3 -1) 
  
  + e1.i <clinit>()
  + e1.i getKey() → String
  + e1.i j(n, int)
  
  - e1.h <init>(int)
  

FIELDS:

   old  │ new  │ diff       
  ──────┼──────┼────────────
   5191 │ 5190 │ -1 (+2 -3) 
  
  + e1.h g: h
  + e1.i g: i
  
  - e1.h g: int
  - e1.h h: h
  - e1.h i: h
  

seem it does possible to lose the Screen.key.

...
  + e1.i getKey() → String
...

mapping.txt

...
com.seiko.demo.voyager_crash_of_kotlin2.HomeScreen -> e1.i:
...

@DevSrSouza
Copy link
Collaborator

Thanks for the finding

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.

2 participants