yggdrasil-network / crispa-android

Community-contributed application for connecting to the Yggdrasil Network on Android devices
https://t.me/yggdrasil_android
Mozilla Public License 2.0
117 stars 22 forks source link

Multidex #86

Closed JeanPaulLucien closed 1 year ago

JeanPaulLucien commented 1 year ago

Yggdrasil 2.1.4 has ~65200 methods. Limit is ~65500. While the app does not need Multidex. Limit is too close, the app needs optimization.

vikulin commented 1 year ago

Fixed in https://github.com/yggdrasil-network/crispa-android/releases/tag/v2.1.7

JeanPaulLucien commented 1 year ago

Fixed in https://github.com/yggdrasil-network/crispa-android/releases/tag/v2.1.7

Crash. Warnings and Errors about kotlin.collections maps and builders. https://kotlinlang.org/api/latest/jvm/stdlib/ https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/#kotlin.collections.Map

JeanPaulLucien commented 1 year ago
WARNING,dalvikvm,Unknown,VFY: unable to resolve static field 27127 (INSTANCE) in Lkotlin/collections/EmptyMap;
DEBUG,dalvikvm,Unknown,VFY: replacing opcode 0x62 at 0x0000
ERROR,dalvikvm,Unknown,Could not find class 'kotlin.collections.builders.MapBuilder', referenced from method kotlin.collections.MapsKt__MapsJVMKt.build
WARNING,dalvikvm,Unknown,VFY: unable to resolve check-cast 6203 (Lkotlin/collections/builders/MapBuilder;) in Lkotlin/collections/MapsKt__MapsJVMKt;
DEBUG,dalvikvm,Unknown,VFY: replacing opcode 0x1f at 0x0005
ERROR,dalvikvm,Unknown,Could not find class 'kotlin.collections.builders.MapBuilder', referenced from method kotlin.collections.MapsKt__MapsJVMKt.createMapBuilder
WARNING,dalvikvm,Unknown,VFY: unable to resolve new-instance 6203 (Lkotlin/collections/builders/MapBuilder;) in Lkotlin/collections/MapsKt__MapsJVMKt;
DEBUG,dalvikvm,Unknown,VFY: replacing opcode 0x22 at 0x0000
ERROR,dalvikvm,Unknown,Could not find class 'kotlin.collections.builders.MapBuilder', referenced from method kotlin.collections.MapsKt__MapsJVMKt.createMapBuilder
WARNING,dalvikvm,Unknown,VFY: unable to resolve new-instance 6203 (Lkotlin/collections/builders/MapBuilder;) in Lkotlin/collections/MapsKt__MapsJVMKt;
DEBUG,dalvikvm,Unknown,VFY: replacing opcode 0x22 at 0x0000
DEBUG,dalvikvm,Unknown,DexOpt: unable to opt direct call 0xbd7e at 0x02 in Lkotlin/collections/MapsKt__MapsJVMKt;.createMapBuilder
DEBUG,dalvikvm,Unknown,DexOpt: unable to opt direct call 0xbd7f at 0x02 in Lkotlin/collections/MapsKt__MapsJVMKt;.createMapBuilder
ERROR,dalvikvm,Unknown,Could not find class 'kotlin.collections.MapWithDefault', referenced from method kotlin.collections.MapsKt__MapWithDefaultKt.getOrImplicitDefaultNullable
WARNING,dalvikvm,Unknown,VFY: unable to resolve instanceof 6178 (Lkotlin/collections/MapWithDefault;) in Lkotlin/collections/MapsKt__MapWithDefaultKt;
DEBUG,dalvikvm,Unknown,VFY: replacing opcode 0x20 at 0x0005
ERROR,dalvikvm,Unknown,Could not find class 'kotlin.collections.MapWithDefault', referenced from method kotlin.collections.MapsKt__MapWithDefaultKt.withDefault
WARNING,dalvikvm,Unknown,VFY: unable to resolve instanceof 6178 (Lkotlin/collections/MapWithDefault;) in Lkotlin/collections/MapsKt__MapWithDefaultKt;
DEBUG,dalvikvm,Unknown,VFY: replacing opcode 0x20 at 0x000a
ERROR,dalvikvm,Unknown,Could not find class 'kotlin.collections.MutableMapWithDefault', referenced from method kotlin.collections.MapsKt__MapWithDefaultKt.withDefaultMutable
WARNING,dalvikvm,Unknown,VFY: unable to resolve instanceof 6187 (Lkotlin/collections/MutableMapWithDefault;) in Lkotlin/collections/MapsKt__MapWithDefaultKt;
DEBUG,dalvikvm,Unknown,VFY: replacing opcode 0x20 at 0x000a
DEBUG,dalvikvm,Unknown,DexOpt: unable to opt direct call 0xbc59 at 0x1b in Lkotlin/collections/MapsKt__MapWithDefaultKt;.withDefault
DEBUG,dalvikvm,Unknown,DexOpt: unable to opt direct call 0xbd08 at 0x1b in Lkotlin/collections/MapsKt__MapWithDefaultKt;.withDefaultMutable
DEBUG,AndroidRuntime,Unknown,Shutting down VM
WARNING,dalvikvm,Unknown,threadid=1: thread exiting with uncaught exception (group=0x4135f930)
JeanPaulLucien commented 1 year ago

In version 2.1.6 and 2.1.7 ~55100 methods.

vikulin commented 1 year ago

Don't see any eroors received in Acra backend prior Android 5.

vikulin commented 1 year ago

@JeanPaulLucien Can you try other Android 4.2 device for?

vikulin commented 1 year ago

@JeanPaulLucien also clear up device cache and re-run app.

JeanPaulLucien commented 1 year ago

@vikulin I uninstall previous version to install new.

vikulin commented 1 year ago

The build is starting to fail after PR #91:

> Task :app:mergeExtDexDebug
ERROR:D8: Cannot fit requested classes in a single dex file (# methods: 93818 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
    at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:151)
    at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:138)

@JeanPaulLucien can you please take a look and make sure Multidex is unnecessary?

JeanPaulLucien commented 1 year ago

@vikulin it's okay. Without multiDexEnabled true IDE shows quantity of methods. I used dexdump -f to know quantity of methods. Before I was sure that all is okay and no mistake that plan is done, but found multiDexEnabled true. Looks like version 2.1.7 is fail build.

As I wrote before, we can decrease quantity of methods. While I do know how exactly. I suggested https://github.com/yggdrasil-network/crispa-android/issues/89 but I don't suppose that over 25000 method will be dropped. IDE can show quantity of methods per class. If you share this info I can help to make R8. You can see how many methods Acra uses (developers did not answer to me). Each dependency adds methods.

https://developer.android.com/studio/build/shrink-code

vikulin commented 1 year ago

@JeanPaulLucien please prepare complete PR with multidex and ACRA fixes.

JeanPaulLucien commented 1 year ago

@vikulin I researched logs for 2.1.6 and found INFORMATION,MultiDex,Yggdrasil,load found 1 secondary dex files Sorry. I did a mistake about MultiDex. Revert https://github.com/yggdrasil-network/crispa-android/commit/aac4459f62c5d6acfc3fafc672e93472d69e6587 and https://github.com/yggdrasil-network/crispa-android/commit/d4f8af5e299e78b584528f680991b4acf2bfdc1c to make workable on Android 4.x again.