英文:
Error when minifying Android app with R8 after upgrading Android Gradle Plugin to 8.0.2
问题
我最近将我的Android应用项目中的Android Gradle插件从版本7.4.2升级到了8.0.2。然而,在执行minifyReleaseWithR8任务时,我现在遇到了一个错误。
我收到的错误消息如下:
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
这个错误似乎与缺少服务类和库类与程序类之间的冲突有关。
只有在我更新了Android Gradle插件后才开始出现这些错误。我尝试过清理项目并确保所有依赖项都是最新的,但问题仍然存在。
是否还有其他人在升级到Android Gradle插件8.0.2时遇到类似的问题?我该如何解决这些错误并成功地使用R8缩小我的发布构建?
任何帮助或建议将不胜感激。谢谢!
英文:
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!
答案1
得分: 1
我们通过将以下内容添加到 app/proguard-rules.pro
中来解决了这个问题:
-dontwarn com.squareup.okhttp.CipherSuite
-dontwarn com.squareup.okhttp.ConnectionSpec
-dontwarn com.squareup.okhttp.TlsVersion
似乎一些混淆警告被视为错误。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论