I recently upgraded the Android Gradle Plugin in my Android app project from version 7.4.2 to 8.0.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:minifyReleaseWithR8
AGPBI: {"kind":"error","text":"Library class android.test.AndroidTestRunner extends program class junit.runner.BaseTestRunner","sources":[{}],"tool":"R8"}
Library class android.test.AndroidTestRunner extends program class junit.runner.BaseTestRunner
AGPBI: {"kind":"error","text":"Library class android.test.InstrumentationTestCase extends program class junit.framework.TestCase","sources":[{}],"tool":"R8"}
Library class android.test.InstrumentationTestCase extends program class junit.framework.TestCase
Task :app:minifyReleaseWithR8 FAILED
The error seems to be related to missing service classes and conflicts between library classes and program classes.
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.0.2? How can I resolve these errors and successfully minify my release build with R8?
Any help or suggestions would be greatly appreciated. Thank you!
We fixed the problem by adding
-dontwarn com.squareup.okhttp.CipherSuite
-dontwarn com.squareup.okhttp.ConnectionSpec
-dontwarn com.squareup.okhttp.TlsVersion
to the app/proguard-rules.pro
.
It seems like some minification warnings were treated as errors.