Getting this error after updating the Android Gradle Plugin from 7.2.1
to 8.0.2
Android studio - Hedgehog | 2023.1.1 Patch 1
Kotlin version - 1.9.23
Java - 17
Crash log -
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
at Version.fakeStackEntry(Version_8.3.37.java:0)
at com.android.tools.r8.InternalCompilationFailedExceptionUtils.create(InternalCompilationFailedExceptionUtils.java:29)
at com.android.tools.r8.utils.ExceptionUtils.failWithFakeEntry(ExceptionUtils.java:145)
at com.android.tools.r8.utils.ExceptionUtils.failCompilation(ExceptionUtils.java:89)
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:83)
at com.android.tools.r8.utils.ExceptionUtils.withR8CompilationHandler(ExceptionUtils.java:69)
at com.android.tools.r8.R8.runForTesting(R8.java:238)
at com.android.tools.r8.R8.run(R8.java:194)
at com.android.builder.dexing.R8Tool.runR8(r8Tool.kt:335)
at com.android.build.gradle.internal.tasks.R8Task$Companion.shrink(R8Task.kt:730)
at com.android.build.gradle.internal.tasks.R8Task$R8Runnable.execute(R8Task.kt:806)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
.
.
.
Caused by: java.lang.NullPointerException: Cannot read field "accessFlags" because the return value of "com.android.tools.r8.graph.AppView.definitionFor(com.android.tools.r8.graph.DexType)" is null
at com.android.tools.r8.ir.optimize.SwitchMapCollector.extractSwitchMap(SwitchMapCollector.java:154)
at com.android.tools.r8.ir.optimize.SwitchMapCollector.lambda$processClasses$0(SwitchMapCollector.java:102)
at com.android.tools.r8.ir.optimize.SwitchMapCollector.processClasses(SwitchMapCollector.java:102)
at com.android.tools.r8.ir.optimize.SwitchMapCollector.run(SwitchMapCollector.java:82)
at com.android.tools.r8.R8.run(R8.java:522)
at com.android.tools.r8.R8.run(R8.java:251)
at com.android.tools.r8.R8.lambda$runForTesting$1(R8.java:242)
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:80)
... 35 more
I tried using the latest R8 version 8.3.37 but still getting the same error.
pluginManagement {
buildscript {
repositories {
mavenCentral()
maven {
url = uri("https://storage.googleapis.com/r8-releases/raw")
}
}
dependencies {
classpath("com.android.tools:r8:8.3.37")
classpath('com.google.guava:guava:33.2.0-jre')
}
}
}
Looks like R8 is processing a SwitchMap on a missing enum. Do you have a reproduction project for the issue? Normally R8 throws if some referenced classes are missing from the input, do you run with ignorewarnings
in your keep rules (a.k.a. proguard configuration)?
I opened b/341991457 in the Google buganizer. I (R8 developer here) will try to make a reproduction, I guess it's ok for R8 to bail out from the switch map optimization in this case, but it would be better if I could reproduce directly your error from a sample project. Not sure how far this can be backported though.