Status Update
Comments
[Deleted User] <[Deleted User]> #2
Full stacktrace from my logcat reproducing the issue
2021-08-13 11:46:20.622 4368-4368/com.adevinta.myapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.adevinta.ourApp, PID: 4368
java.lang.RuntimeException: Unable to instantiate application com.adevinta.myapp.MyApplication: java.lang.ClassNotFoundException: Didn't find class "com.adevinta.myapp.MyApplication" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.adevinta.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.adevinta.myapp-1/lib/x86, /data/app/com.adevinta.myapp-1/base.apk!/lib/x86, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:578)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.adevinta.myapp.MyApplication" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.adevinta.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.adevinta.myapp-1/lib/x86, /data/app/com.adevinta.myapp-1/base.apk!/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newApplication(Instrumentation.java:981)
at android.app.LoadedApk.makeApplication(LoadedApk.java:573)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Suppressed: java.lang.ClassNotFoundException: com.adevinta.myapp.MyApplication
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
[Deleted User] <[Deleted User]> #3
AGP 7.0.0
R8
failing: 3.0.43 to 3.0.65 (both included)
works fine: <= 3.0.42 and >= 3.1
sg...@google.com <sg...@google.com> #4
Thank you for the report and the analysis of the R8 version introducing the issue. Would it be possible for you to share the APK of both a working and a broked version of your app.?E.g. one built with 3.0.43 and one built with 3.0.42? You can share them privately with
[Deleted User] <[Deleted User]> #5
After further testing we've found that the build with 3.0.42 is also failing, at this point I'm not sure if it's something random or an error while building the test apks...
The 3.1.X build is working fine though... I'll send you the apks failing and the one working
mk...@google.com <mk...@google.com> #6
Thank you for sending the apks. This issue is indeed strange. The missing class is defined in classes13.dex and I've double checked and it is also in the /data/app/<name-here>-1/base.apk
. Can I ask you to try out the following just to see if anything helps:
- If you have anything like INSTANT_RUN enabled, disable it.
- Does the apk without the test work?
- Can you easily see what happens if you disable firebase, we have seen errors with that before since it is not case sensitive.
[Deleted User] <[Deleted User]> #7
- I'm running
gradle installRelease
to build and install the apk, AFAIK nothing related to instant run is enabled (any concrete setting that I should try??) - I'm not sure what do you mean with this, If I don't override the R8 version the apk crashes..
- We use Firebase Performance and Firebase Crashlytics, We've tried a build without Firebase Performance with no luck, I'll try also without Firebase Crashlytics and report the results.
mk...@google.com <mk...@google.com> #8
Found the error I had to use a newer device for the error to be reported:
08-17 10:37:53.488 1091 1091 W m.muba.anuncio: Zip open failed: Failure to verify dex file '/data/app/com.muba.anuncios-zqK-p_wxoHYFSUnuQrdkUw==/base.apk!classes7.dex': Out-of-order type_ids: 32ef then 32ef
I may need more information when I find the types that are duplicated if I am unable to find the root cause.
[Deleted User] <[Deleted User]> #9
What would you need from us to further help debugging the issue?
mk...@google.com <mk...@google.com> #10
The offending class is Lcom/appsflyer/internal/c;
which is added twice to the type-id-pool. Can you look and see in the mapping file for each of the apks if there are two mappings to the same?
Also, it is quite difficult to figure out why this error appear and exactly where the error is. Would it be possible to share a dump with us, then I can figure out the error locally without any more involvement. You can read about how a dump is created here:
Note that we get the compiled sources by javac/kotlin but we can run the compiler on it locally to figure out the exact problem.
If not we will have to iterate where I will put in extra debugging info into a custom built R8 version. If that is the case it would be a great help if:
- If you first try and run with
-dontobfuscate
and see if the error still exist - If I knew the original name (or names if there are two mappings) (you can send the name privately)
[Deleted User] <[Deleted User]> #11
For some reason it isn't generating the dump file using the R8 version that is failing... I have been able to generate the dump using com.android.tools:r8:3.1.15-dev
without any issues.
I've looked for the offending class in the mappings (generated with the production r8 version and dev version is the same output)
com.appsflyer.internal.c$2 -> com.appsflyer.internal.c$2:
# {"id":"sourceFile","fileName":""}
1:1:void <init>():22:22 -> <init>
2:23:void <init>():24:45 -> <init>
com.appsflyer.internal.c$b -> com.appsflyer.internal.c$b:
# {"id":"sourceFile","fileName":""}
1:1:void <clinit>():319:319 -> <clinit>
2:2:void <clinit>():318:318 -> <clinit>
1:2:void <init>(java.lang.String,int,java.lang.String):323:324 -> <init>
1:1:com.appsflyer.internal.c$b valueOf(java.lang.String):318:318 -> valueOf
1:1:com.appsflyer.internal.c$b[] values():318:318 -> values
com.appsflyer.internal.c$d -> com.appsflyer.internal.c$d:
# {"id":"sourceFile","fileName":""}
1:1:void <clinit>():302:302 -> <clinit>
2:2:void <clinit>():301:301 -> <clinit>
1:2:void <init>(java.lang.String,int,java.lang.String):306:307 -> <init>
1:1:com.appsflyer.internal.c$d valueOf(java.lang.String):301:301 -> valueOf
1:1:com.appsflyer.internal.c$d[] values():301:301 -> values
com.appsflyer.internal.c$e -> com.appsflyer.internal.c$e:
# {"id":"sourceFile","fileName":""}
1:1:void <clinit>():285:285 -> <clinit>
2:2:void <clinit>():284:284 -> <clinit>
1:2:void <init>(java.lang.String,int,java.lang.String):289:290 -> <init>
1:1:com.appsflyer.internal.c$e valueOf(java.lang.String):284:284 -> valueOf
1:1:com.appsflyer.internal.c$e[] values():284:284 -> values
We can try the custom R8 build if you want
mk...@google.com <mk...@google.com> #12
Seems like com.appsflyer is already minified.
The dump is the same except some configuration for each version so I would be very interested in the dump generated by version 3.1.15-dev :) you can send it to
ap...@google.com <ap...@google.com> #13
Branch: main
commit 77eab0ae1a6a916da84de8bb017cdcf494871426
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Thu Aug 19 14:12:34 2021
Add reproduction for class name minifier picking missing class name
Bug: 196406764
Change-Id: Id51cea98633d5c32972966fe4fa7ec6c4fc25a96
A src/test/java/com/android/tools/r8/naming/MissingReferenceNamingClashTest.java
M src/test/java/com/android/tools/r8/transformers/ClassFileTransformer.java
ap...@google.com <ap...@google.com> #14
Branch: main
commit e1e91b0fb82a097893d449d27cf6c88865038e1a
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Thu Aug 19 14:15:32 2021
Account for missing type in class name minification
Bug: 196406764
Change-Id: Ia547424f8b89f1a6c88af254938c6675b00631ff
M src/main/java/com/android/tools/r8/naming/ClassNameMinifier.java
M src/main/java/com/android/tools/r8/shaking/MissingClasses.java
M src/test/java/com/android/tools/r8/naming/MissingReferenceNamingClashTest.java
ap...@google.com <ap...@google.com> #15
Branch: main
commit 679251cd80562e17c16d2e05b85564008fd8c641
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Fri Aug 20 12:25:09 2021
Check for missing classes when repackaging class
Bug: 196406764
Change-Id: I0a641c568de090445da6188cc5c3ea37e72793a5
M src/main/java/com/android/tools/r8/repackaging/Repackaging.java
M src/test/java/com/android/tools/r8/repackage/RepackageMissingTypeCollisionTest.java
ap...@google.com <ap...@google.com> #16
Branch: main
commit 31c59985be5b653d0d3eda43b1d83c94947831da
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Fri Aug 20 12:24:49 2021
Add test for repackaging collision with missing class
Bug: 196406764
Change-Id: Ia16d9ec7a770eaf5d8fd9bfc21eef5cbe362b0e0
M src/main/java/com/android/tools/r8/graph/GraphLens.java
A src/test/java/com/android/tools/r8/repackage/RepackageMissingTypeCollisionTest.java
M src/test/java/com/android/tools/r8/transformers/ClassFileTransformer.java
ap...@google.com <ap...@google.com> #17
Branch: 3.0
commit 4e52ac0bbdf5dc898b687bc9f4e01002a34d5611
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Mon Aug 23 09:31:09 2021
Version 3.0.68
Bug: 196406764
Bug: 197480128
Change-Id: Icb4e3f67c31bc277ced45020eab4ea2229cf3db9
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #18
Branch: 3.0
commit e8e55732974403e793f914a9eff22fcaaebd5de6
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Mon Aug 23 09:30:07 2021
Check for missing classes when repackaging class
Bug: 196406764
Change-Id: I0a641c568de090445da6188cc5c3ea37e72793a5
M src/main/java/com/android/tools/r8/repackaging/Repackaging.java
M src/test/java/com/android/tools/r8/repackage/RepackageMissingTypeCollisionTest.java
ap...@google.com <ap...@google.com> #19
Branch: 3.0
commit d102e1d72e517267c733f5f5a167391baf6497a4
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Mon Aug 23 09:29:45 2021
Add test for repackaging collision with missing class
Bug: 196406764
Change-Id: Ia16d9ec7a770eaf5d8fd9bfc21eef5cbe362b0e0
M src/main/java/com/android/tools/r8/graph/GraphLens.java
A src/test/java/com/android/tools/r8/repackage/RepackageMissingTypeCollisionTest.java
M src/test/java/com/android/tools/r8/transformers/ClassFileTransformer.java
ap...@google.com <ap...@google.com> #20
Branch: 3.0
commit 4f06accae071b3d829054e30d8f639f198457c92
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Mon Aug 23 09:29:12 2021
Account for missing type in class name minification
Bug: 196406764
Change-Id: Ia547424f8b89f1a6c88af254938c6675b00631ff
M src/main/java/com/android/tools/r8/naming/ClassNameMinifier.java
M src/main/java/com/android/tools/r8/shaking/MissingClasses.java
M src/test/java/com/android/tools/r8/naming/MissingReferenceNamingClashTest.java
ap...@google.com <ap...@google.com> #21
Branch: 3.0
commit 07392982dc8bb0cc37a4b5f56d894401b62d6d0c
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Mon Aug 23 09:28:38 2021
Add reproduction for class name minifier picking missing class name
Bug: 196406764
Change-Id: Id51cea98633d5c32972966fe4fa7ec6c4fc25a96
A src/test/java/com/android/tools/r8/naming/MissingReferenceNamingClashTest.java
M src/test/java/com/android/tools/r8/transformers/ClassFileTransformer.java
mk...@google.com <mk...@google.com> #22
The error has now been fixed. The reason why this was failing with out of order type-ids was due to us not accounting for missing type names when renaming classes. The error has now been fixed and I've created a new version that you could try out:
buildscript {
repositories {
maven {
url 'https://storage.googleapis.com/r8-releases/raw'
}
}
dependencies {
classpath 'com.android.tools:r8:3.0.68' // Must be before the Gradle Plugin for Android.
classpath 'com.android.tools.build:gradle:X.Y.Z' // Your current AGP version.
}
}
Thank you for your help in tracking this bug down.
[Deleted User] <[Deleted User]> #23
I just tested it and it works as expected, thank you for the quick response :)
mk...@google.com <mk...@google.com> #24
Thank you for confirming that it works - the change has been rolled into studio and will be included in any new releases.
Description
We've updated to AGP7 and we've found that the release build with R8 crashes upon starting the app with.
When running it in some devices we see that it can't find the application class.
We've tried overriding the R8 version and found that it fails since the version 3.0.43, the version 3.0.42 seems to work fine.
Any tips about what can it be? I've looked at the 3 commits between those releases, but I don't understand what is going on :sorry: