I recently upgraded the Android Gradle Plugin in my Android app project from version 7.4.2 to 8.2.2. However, I'm now encountering an error during the release build when the minifyReleaseWithR8 task is executed.
The error message I'm getting is as follows:
Task :app:minifyKioskDebugWithR8 FAILED AGPBI: {"kind":"error","text":"com.android.tools.r8.ResourceException: com.android.tools.r8.internal.vc: I/O exception while reading '/Users/harinikesh/StudioProjects/instore/app/build/intermediates/merged_java_res/kioskDebug/base.jar': /Users/harinikesh/StudioProjects/instore/app/build/intermediates/merged_java_res/kioskDebug/base.jar","sources":[{"file":"/Users/harinikesh/StudioProjects/instore/app/build/intermediates/merged_java_res/kioskDebug/base.jar"}],"tool":"R8"} com.android.tools.r8.ResourceException: com.android.tools.r8.internal.vc: I/O exception while reading '/Users/harinikesh/StudioProjects/instore/app/build/intermediates/merged_java_res/kioskRelease/base.jar': /Users/harinikesh/StudioProjects/instore/app/build/intermediates/merged_java_res/kioskRelease/base.jar
I got this error while generating the release build with
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'}
I tried making the shrinkResources and minifyEnabled to false, Build got successful.
These errors only started occurring after I updated the Android Gradle Plugin. I've tried cleaning the project and ensuring that all dependencies are up to date, but the issue persists.
Has anyone else encountered a similar issue when upgrading to Android Gradle Plugin 8.2.2? How can I resolve these errors and successfully minify my release build with R8?
We were getting the exact same error. After viewing the stacktrace by using ./gradlew --stacktrace :app:minifyReleaseWithR8
as suggested by sgjesse
we realized the error was happening because a file was not found during the build process.
Within our app build.gradle file we have a tasks.whenTaskAdded {
closure that renames the bundle when we create a build. Within this closure a file is renamed/moved. After removing this renaming logic from our build.gradle file the error was resolved.
Note that I'm sure it's possible to correct the renaming logic. In our case we did not need it and decided to remove.