Status Update
Comments
za...@capitalone.com <za...@capitalone.com> #2
Okay. I tried a bunch of agp+android studio versions
The last working version was classpath("com.android.tools.build:gradle:7.4.0-alpha06")
once I moved to
classpath("com.android.tools.build:gradle:7.4.0-alpha07")
then things start breaking on firebase app dist.
za...@capitalone.com <za...@capitalone.com> #3
Scott, assigning to you as it seem to complain the zip is not aligned while packaging which is very puzzling considering the steps...
sg...@google.com <sg...@google.com> #4
OP, when you build the APK with AGP, are you doing any post-processing on the APK and/or do you have any custom tasks that are modifying the APK?
Can you try to verify the alignment of your APK with zipalign
locally (zipalign
is included in build-tools
):
zipalign -c -v 4 foo.apk
sg...@google.com <sg...@google.com> #5
Not doing any post processing. No custom tasks. I will try to verify alignment now. Give me a sec.
my...@gmail.com <my...@gmail.com> #6
Scenario 1:
built my apk with agp alpha09, but didn't update firebase (bom = 30.2.0)
/Users/idle/Library/Android/sdk/build-tools/31.0.0/zipalign -c -v 4 app-release.apk
"Verification succesful"
Scenario 2:
built my apk with agp alpha09, but I DID update firebase (bom = 30.3.1)
/Users/idle/Library/Android/sdk/build-tools/31.0.0/zipalign -c -v 4 app-release.apk
"Verification FAILED"
my...@gmail.com <my...@gmail.com> #7
Scenario 3:
built my apk with agp alpha09, with androidx.splash rc01
/Users/idle/Library/Android/sdk/build-tools/31.0.0/zipalign -c -v 4 app-release.apk
"Verification succesful"
Scenario 4:
built my apk with agp alpha09, with androidx.splash 1.0.0
/Users/idle/Library/Android/sdk/build-tools/31.0.0/zipalign -c -v 4 app-release.apk
"Verification FAILED"
In both failed cases if I do | grep BAD
I get
7216334 junit/runner/logo.gif (BAD - 2)
7217354 junit/runner/smalllogo.gif (BAD - 2)
sg...@google.com <sg...@google.com> #8
In the cases where zipalign
verification fails, is the APK generated by a clean build (e.g., ./gradlew clean :app:assembleRelease
)?
Does verification succeed if you add this to your build.gradle?
android {
packagingOptions {
exclude 'junit/runner/logo.gif'
exclude 'junit/runner/smalllogo.gif'
}
}
sg...@google.com <sg...@google.com> #9
In the cases where zipalign verification fails, is the APK generated by a clean build (e.g., ./gradlew clean :app:assembleRelease)?
I clean before i generate the apk using the Android Studio menu for generating an apk
Does verification succeed if you add this to your build.gradle?
I assume it will, but let me try. Any reason why changing from androidx.splash 1.0.0-rc01 to 1.0.0 stable (which is 0 changes. all it changed was the dependency version) that it fails verification. It seems like something else is wrong that's a bit deeper than just adding these two exclude statements.
mk...@google.com <mk...@google.com> #10
It seems like something else is wrong that's a bit deeper than just adding these two exclude statements.
I agree, but I'd like to find a workaround for you in the meantime.
I think I'll probably need a repro project to get to the bottom of it. In your other thread, it sounded like you weren't able to create a repro project... any luck since then?
ap...@google.com <ap...@google.com> #11
I was not able to create a repro unfortunately. As soon as I started to prune things out of my project it started to succeed.
Similarly. firebase came out with a new version. and if i use that new version... then it also succeeds. 🤯
I'm glad to hear there is a workaround for now (and i learned something new about zipalign). I will try to create a repo project again later today when I have about an hour or so free to play around with it, but for now I will just commit the
android {
packagingOptions {
exclude 'junit/runner/logo.gif'
exclude 'junit/runner/smalllogo.gif'
}
}
to my codebase because that did the trick for me. Everything works. Thank you for your quick response and helpful debugging steps.
ap...@google.com <ap...@google.com> #12
Thanks!
ap...@google.com <ap...@google.com> #13
not able to get a repro case. literally any minor thing i change makes this verify successfully. im a bit out of ideas. the only thing i can think of that might help is why is junit being packaged into my app.
and i think the reason for that is that I depend on okhttp3:mockwebserver:4.10.0
implementation("junit:junit:4.13.2") // Needed because mockwebserver has a dependency on it. This can be removed in okhttp 5+
so the apps i ship through firebase have a mockwebserver using okhttpmockwebserver, but version 4+ requires junit while okhttp 5+ (not yet released), removes this dep.
so maybe just playing around with adding junit as a dependency to an actual app might help repro?
source:
maybe still owrth checking out as there could be other deps that end up with the same issue. idk. just trying to be helpful i guess. but as for me. im going to consider this case closed. excluding the above like you mentioned has unblocked my team. cheers
ap...@google.com <ap...@google.com> #14
Thanks for looking into it!
I agree it's strange they have an implementation
dependency on junit, and I'm glad they're removing it in okhttp 5+.
I'll go ahead and close this bug for now.
ap...@google.com <ap...@google.com> #15
This is fixed by Change-Id: I12ec8785cd4dbb6e523c66b4620ed2388f448822, which will be in AGP 7.4.0-rc01 and 8.0.0-alpha08.
ap...@google.com <ap...@google.com> #16
Thanks for filing the bug, OP. Your observation in
ap...@google.com <ap...@google.com> #17
FUCK YEAH! Glad I was helpful! Appreciate you working through it with me here. Cheers. Once I update to alpha08 I will remove the workaround I added. cheers
ap...@google.com <ap...@google.com> #18
Branch: 8.0
commit 412f08f108d722837f41fc33ea4e69226a45b031
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Tue Dec 20 09:11:19 2022
Add test for trying to compute method states for dynamic null receiver
Bug:
Change-Id: I7ca63f38483c1e953b42c8b1737974f5b6897039
M src/main/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagatorCodeScanner.java
M src/main/java/com/android/tools/r8/utils/InternalOptions.java
A src/test/java/com/android/tools/r8/optimize/argumentpropagation/PolymorphicMethodWithNullReceiverBoundTest.java
my...@gmail.com <my...@gmail.com> #19
4.0.49 fixes at least my problem! Thanks!
ap...@google.com <ap...@google.com> #20
Branch: main
commit a0b5226d8b06317f51e6f94752b40dbe2b7ee328
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Tue Dec 20 16:07:23 2022
Update null cyclic phis when rewriting always throwing instructions
Bug:
Change-Id: I3a26861b028c553e8bb5c66ae30f335d19bc40c4
M src/main/java/com/android/tools/r8/ir/analysis/type/DestructivePhiTypeUpdater.java
M src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java
mk...@google.com <mk...@google.com> #21
Great to hear. For others seeing the same problem version 4.0.49 can be used by adding the following to the build.gradle file:
pluginManagement {
buildscript {
repositories {
mavenCentral()
maven {
url = uri("https://storage.googleapis.com/r8-releases/raw")
}
}
dependencies {
classpath("com.android.tools:r8:4.0.49")
}
}
}
my...@gmail.com <my...@gmail.com> #22
Would this land in 7.4.0 stable? It doesn't seem to have landed in rc03...
mk...@google.com <mk...@google.com> #23
This will not land in stable. The version on that branch is 4.0.48 at most, 4.0.49 has not been checked in.
dm...@izettle.com <dm...@izettle.com> #24
mk...@google.com <mk...@google.com> #25
Please ensure that you have setup the specific dependency on R8 to be version 4.0.51 and that you are not specifiying the version other places (such as buildSrc).
dm...@izettle.com <dm...@izettle.com> #26
Yes, my previous stacktrace was from 4.0.48. It was trickier to update than I thought. After really updating to 4.0.51 I started to get new trace
Caused by: java.lang.NullPointerException
at com.android.tools.r8.shaking.Enqueuer.markTypeAsLive(Enqueuer.java:2012)
at com.android.tools.r8.shaking.Enqueuer.traceTypeReference(Enqueuer.java:1388)
at com.android.tools.r8.shaking.DefaultEnqueuerUseRegistry.registerTypeReference(DefaultEnqueuerUseRegistry.java:174)
at com.android.tools.r8.cf.code.CfFrame.internalRegisterUse(CfFrame.java:273)
at com.android.tools.r8.cf.code.CfFrame.lambda$internalRegisterUse$1(CfFrame.java:264)
at com.android.tools.r8.cf.code.CfFrame.internalRegisterUse(CfFrame.java:264)
at com.android.tools.r8.cf.code.CfInstruction.registerUse(CfInstruction.java:104)
at com.android.tools.r8.graph.CfCode.registerCodeReferences(CfCode.java:683)
at com.android.tools.r8.graph.LazyCfCode.registerCodeReferences(LazyCfCode.java:284)
at com.android.tools.r8.graph.ProgramMethod.registerCodeReferences(ProgramMethod.java:127)
at com.android.tools.r8.shaking.Enqueuer.traceCode(Enqueuer.java:4809)
at com.android.tools.r8.shaking.Enqueuer.traceNonDesugaredCode(Enqueuer.java:4803)
at com.android.tools.r8.shaking.Enqueuer.markMethodAsLive(Enqueuer.java:4742)
at com.android.tools.r8.shaking.EnqueuerWorklist$MarkMethodLiveAction.run(EnqueuerWorklist.java:166)
at com.android.tools.r8.shaking.Enqueuer.trace(Enqueuer.java:4395)
at com.android.tools.r8.shaking.Enqueuer.traceApplication(Enqueuer.java:3622)
at com.android.tools.r8.R8.runEnqueuer(R8.java:1012)
at com.android.tools.r8.R8.run(R8.java:369)
at com.android.tools.r8.R8.run(R8.java:252)
at com.android.tools.r8.R8.lambda$runForTesting$1(R8.java:243)
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:80)
... 35 more
R8 is a new Android code shrinker. If you experience any issues, please file a bug at
https://issuetracker.google.com, using 'Shrinker (R8)' as component name.
Current version is: 4.0.51 (build 41681a871b6a304b5c57388bf833ab1417e17ca9 from go/r8bot (luci-r8-custom-ci-bionic-22-vlxz)).
mk...@google.com <mk...@google.com>
dm...@izettle.com <dm...@izettle.com> #27
FYI. Downgrading R8 to 3.3.75 solved the issue.
dm...@izettle.com <dm...@izettle.com> #29
I don't think I can share a dump, it will be against company policy, sorry.
mk...@google.com <mk...@google.com> #30
Can you try to run with assertions enabled then?
./gradlew assembleRelease -Dorg.gradle.jvmargs='-ea:com.android.tools.r8'
or set the jvmargs in the gradle properties. Hopefully we will see where the error first appear then.
dm...@izettle.com <dm...@izettle.com> #31
I did this and I got these messages. There were more lines like that, I removed project-specific ones for security reasons. Is this what you was looking for?
Unable to find common super type for androidx/window/extensions/embedding/SplitPlaceholderRule and androidx/window/extensions/embedding/ActivityRule.
Unable to find common super type for androidx/window/extensions/embedding/SplitPairRule and java/lang/Object.
Unable to find common super type for com/google/common/util/concurrent/ListenableFuture and java/util/ArrayList.
Unable to find common super type for kotlin/Pair and java/lang/Object.
Unable to find common super type for okhttp3/Response and java/lang/Object.
Unable to find common super type for okhttp3/OkHttpClient and java/lang/Object.
Unable to find common super type for java/lang/Object and kotlin/Pair.
Unable to find common super type for java/lang/Exception and com/google/android/gms/tasks/Task.
Unable to find common super type for kotlinx/coroutines/CoroutineScope and java/lang/Object.
Unable to find common super type for java/lang/Object and kotlinx/coroutines/CoroutineScope.
Unable to find common super type for java/lang/NoClassDefFoundError and [REDACTED].
Current version is: 4.0.51 (build 41681a871b6a304b5c57388bf833ab1417e17ca9 from go/r8bot (luci-r8-custom-ci-bionic-22-vlxz)).
mk...@google.com <mk...@google.com> #32
No, that is not what I was looking for I am looking for a stack trace that is not the NPE. Running with assertions enabled should give a better indication of the origin of the error. The problem is that an object is constructed with a field that is null
. That is the NPE you are seeing. Internally we have an assert that such an object cannot be created so running with assertions would move the exception to creation time.
Potentially the argument should be:
-ea:com.android.tools.r8...
You should be able to specify it both by the command line and the gradle.properties file.
Please also run with --no-daemon
to ensure it will create a fresh VM.
dm...@izettle.com <dm...@izettle.com> #33
I did ./gradlew assembleRelease -Dorg.gradle.jvmargs='-ea:com.android.tools.r8' --no-daemon --stacktrace
and got the same stacktrace as initially, the one with NPE.
mk...@google.com <mk...@google.com> #34
Did you try:
./gradlew assembleRelease -Dorg.gradle.jvmargs='-ea:com.android.tools.r8...' --no-daemon --stacktrace
(notice the dots in the end of r8.)
dm...@izettle.com <dm...@izettle.com> #35
I've tried with dots and got new callstack :)
Caused by: java.lang.NullPointerException
at com.android.tools.r8.cf.code.frame.UninitializedNew.<init>(UninitializedNew.java:22)
at com.android.tools.r8.cf.code.frame.FrameType.uninitializedNew(FrameType.java:135)
at com.android.tools.r8.graph.LazyCfCode$MethodCodeVisitor.getFrameType(LazyCfCode.java:542)
at com.android.tools.r8.graph.LazyCfCode$MethodCodeVisitor.parseStack(LazyCfCode.java:521)
at com.android.tools.r8.graph.LazyCfCode$MethodCodeVisitor.visitFrame(LazyCfCode.java:501)
at com.android.tools.r8.org.objectweb.asm.ClassReader.readCode(ClassReader.java:2068)
at com.android.tools.r8.org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1514)
at com.android.tools.r8.org.objectweb.asm.ClassReader.accept(ClassReader.java:744)
at com.android.tools.r8.org.objectweb.asm.ClassReader.accept(ClassReader.java:424)
at com.android.tools.r8.graph.LazyCfCode.parseCode(LazyCfCode.java:205)
at com.android.tools.r8.graph.LazyCfCode.internalParseCode(LazyCfCode.java:161)
at com.android.tools.r8.utils.ExceptionUtils.lambda$withOriginAndPositionAttachmentHandler$5(ExceptionUtils.java:238)
at com.android.tools.r8.utils.ExceptionUtils.withOriginAndPositionAttachmentHandler(ExceptionUtils.java:246)
at com.android.tools.r8.utils.ExceptionUtils.withOriginAndPositionAttachmentHandler(ExceptionUtils.java:234)
at com.android.tools.r8.utils.ExceptionUtils.withOriginAttachmentHandler(ExceptionUtils.java:225)
at com.android.tools.r8.graph.LazyCfCode.asCfCode(LazyCfCode.java:143)
at com.android.tools.r8.ir.desugar.NonEmptyCfInstructionDesugaringCollection.needsDesugaring(NonEmptyCfInstructionDesugaringCollection.java:349)
at com.android.tools.r8.shaking.Enqueuer.addToPendingDesugaring(Enqueuer.java:4004)
at com.android.tools.r8.shaking.Enqueuer.traceNonDesugaredCode(Enqueuer.java:4798)
at com.android.tools.r8.shaking.Enqueuer.markMethodAsLive(Enqueuer.java:4742)
at com.android.tools.r8.shaking.EnqueuerWorklist$MarkMethodLiveAction.run(EnqueuerWorklist.java:166)
at com.android.tools.r8.shaking.Enqueuer.trace(Enqueuer.java:4395)
at com.android.tools.r8.shaking.Enqueuer.traceApplication(Enqueuer.java:3622)
at com.android.tools.r8.R8.runEnqueuer(R8.java:1012)
at com.android.tools.r8.R8.run(R8.java:369)
at com.android.tools.r8.R8.run(R8.java:252)
at com.android.tools.r8.R8.lambda$runForTesting$1(R8.java:243)
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:80)
... 35 more
Suppressed: com.android.tools.r8.utils.ExceptionUtils$OriginAttachmentException: java.lang.NullPointerException
at com.android.tools.r8.utils.ExceptionUtils$OriginAttachmentException.wrap(ExceptionUtils.java:258)
at com.android.tools.r8.utils.ExceptionUtils.withOriginAndPositionAttachmentHandler(ExceptionUtils.java:248)
at com.android.tools.r8.utils.ExceptionUtils.withOriginAndPositionAttachmentHandler(ExceptionUtils.java:234)
at com.android.tools.r8.utils.ExceptionUtils.withOriginAttachmentHandler(ExceptionUtils.java:225)
at com.android.tools.r8.graph.LazyCfCode.asCfCode(LazyCfCode.java:143)
at com.android.tools.r8.ir.desugar.NonEmptyCfInstructionDesugaringCollection.needsDesugaring(NonEmptyCfInstructionDesugaringCollection.java:349)
at com.android.tools.r8.shaking.Enqueuer.addToPendingDesugaring(Enqueuer.java:4004)
at com.android.tools.r8.shaking.Enqueuer.traceNonDesugaredCode(Enqueuer.java:4798)
at com.android.tools.r8.shaking.Enqueuer.markMethodAsLive(Enqueuer.java:4742)
at com.android.tools.r8.shaking.EnqueuerWorklist$MarkMethodLiveAction.run(EnqueuerWorklist.java:166)
at com.android.tools.r8.shaking.Enqueuer.trace(Enqueuer.java:4395)
at com.android.tools.r8.shaking.Enqueuer.traceApplication(Enqueuer.java:3622)
at com.android.tools.r8.R8.runEnqueuer(R8.java:1012)
at com.android.tools.r8.R8.run(R8.java:369)
at com.android.tools.r8.R8.run(R8.java:252)
at com.android.tools.r8.R8.lambda$runForTesting$1(R8.java:243)
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:80)
at com.android.tools.r8.utils.ExceptionUtils.withR8CompilationHandler(ExceptionUtils.java:69)
at com.android.tools.r8.R8.runForTesting(R8.java:239)
at com.android.tools.r8.R8.run(R8.java:187)
at com.android.builder.dexing.R8Tool.runR8(r8Tool.kt:308)
at com.android.build.gradle.internal.tasks.R8Task$Companion.shrink(R8Task.kt:642)
at com.android.build.gradle.internal.tasks.R8Task$R8Runnable.execute(R8Task.kt:712)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)
at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:212)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:187)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:120)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:162)
at org.gradle.internal.Factories$1.create(Factories.java:31)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:249)
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:109)
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:114)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:157)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:126)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: [CIRCULAR REFERENCE: java.lang.NullPointerException]
ap...@google.com <ap...@google.com> #36
Branch: main
commit d3be3e93b26b4797fcfa4b071da30e5184ac27b5
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Thu Feb 02 10:38:36 2023
Throw compilation error with origin when failing to parse code
Bug:
Change-Id: I358dc5d95aacfe448ec9d1e2d5e5d5deb4921631
M src/main/java/com/android/tools/r8/graph/LazyCfCode.java
mk...@google.com <mk...@google.com> #37
I've created a new CL ToT that will show the origin of the class-file we cannot parse. Hopefully you can share that library/file with us. To use the new version, you have amend your build.gradle file:
pluginManagement {
buildscript {
repositories {
mavenCentral()
maven {
url = uri("https://storage.googleapis.com/r8-releases/raw/main")
}
}
dependencies {
classpath("com.android.tools:r8:d3be3e93b26b4797fcfa4b071da30e5184ac27b5")
classpath('com.google.guava:guava:30.1.1-jre') // <-- THIS IS REQUIRED UNTIL R8 3.2.4-dev
}
}
}
(Note that the maven repository is different)
Then run the .gradlew command again.
mk...@google.com <mk...@google.com> #38
I will close this bug waiting for answer since it marked as P1 and cannot change it since we backported an issue. Please open a new bug when you have the source files that we cannot parse.
Description
Getting the following exception when executing
:app:minifyVariantWithR8
when upgrading to7.4.0-beta02
. This worked without issues with AGP7.3.0
.