因为混淆的问题生成Release版本失败
发布日期:2021-05-10 05:21:52 浏览次数:24 分类:技术文章

本文共 3207 字,大约阅读时间需要 10 分钟。

生成Release版本失败

异常是

Note: there were 19 references to unknown classes.      You should check your configuration for typos.      (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)Note: there were 1170 unkept descriptor classes in kept class members.      You should consider explicitly keeping the mentioned classes      (using '-keep').      (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)Note: there were 41 unresolved dynamic references to classes or interfaces.      You should check if you need to specify additional program jars.      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)Warning: there were 1325 unresolved references to classes or interfaces.         You may need to add missing library jars or update their versions.         If your code works fine without the missing classes, you can suppress         the warnings with '-dontwarn' options.         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)Warning: there were 8 unresolved references to program class members.         Your input classes appear to be inconsistent.         You may need to recompile the code.         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.Thread(Tasks limiter_2): destruction:demo:transformClassesAndResourcesWithProguardForBetaRelease FAILEDFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':demo:transformClassesAndResourcesWithProguardForBetaRelease'.> Job failed, see logs for details* Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.* Get more help at https://help.gradle.orgBUILD FAILED in 40s60 actionable tasks: 17 executed, 38 from cache, 5 up-to-date17:05:49: Task execution finished 'assembleRelease'.

可以看出来,我们就是混淆有问题,接下来解决。

找到异常位置

在这里插入图片描述

向上翻

在这里插入图片描述

如图,就是异常的原因,需要一个一个解决。

解决

在这里插入图片描述

有些异常的原因,比如说是阿里云推送的混淆异常(上图),直接去官网找,有一些就需要摸索了。

自行解决混淆问题参考:

-dontwarn com.xx.bbb.**-keep class com.xx.bbb.** {
*;}# -keep interface com.xx.bbb.** {
*;}

测试

当通过build工具,已经可以生产release版本APK,这说明我们已经初步达成~

接下来,使用混淆的版本运行即可,只要正常运行不发生崩溃就没什么问题了。

buildTypes {
debug {
buildConfigField "boolean", "LOG_DEBUG", "true" buildConfigField "boolean", "ENVIRONMENT_BETA", "true" minifyEnabled true//混淆 multiDexEnabled true//分包 65535 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } release {
buildConfigField "boolean", "LOG_DEBUG", "false" buildConfigField "boolean", "ENVIRONMENT_BETA", "true" minifyEnabled true//混淆 multiDexEnabled true//分包 65535 shrinkResources true//资源缩减 zipAlignEnabled true//Zipalign优化->数据对齐->更快速调用APP内资源 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } android.applicationVariants.all {
//版本名称 variant -> generateAppName(variant) } }

如图,把debug版本也设置上混淆,直接运行查看即可。

转载地址:https://blog.csdn.net/weixin_35691921/article/details/109494526 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Canvas 绘制方法过一遍
下一篇:混淆规则内容包含什么?项目中的混淆文件拉出来溜溜

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年10月25日 21时32分52秒