Gradle build报错:Please correct the above warnings first解决方案

转载请标明出处:http://blog.csdn.net/xx326664162/article/details/52387583 文章出自:薛瑄的博客

你也可以查看我的其他同类文章,也会让你有一定的收货

问题描述:

在编译的时候,出现了下面的错误提示

Warning: there were 2 unresolved references to library class members.
         You probably need to update the library versions.
         Alternatively, you may have to specify the option 
         '-dontskipnonpubliclibraryclassmembers'.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
 java.io.IOException: Please correct the above warnings first.

分析:

上面提示编译过程中出现了warning,要求修复,所以停止了编译。

按照上面的提示在混淆配置文件proguard-rules.pro中增加-dontskipnonpubliclibraryclassmembers项,也不会起作用。

只能按上面提示寻找warings,如下Log中的中间两行Waring:

Note: the configuration refers to the unknown class 'com.alipay.mobile.security.senative.APSE'
Warning: com.baidu.platform.comapi.map.e: can't find referenced method 'float sqrt(float)' in library class android.util.FloatMath
Warning: com.tencent.connect.avatar.c: can't find referenced method 'float sqrt(float)' in library class android.util.FloatMath
Note: android.support.v4.text.ICUCompatIcs: can't find dynamically referenced class libcore.icu.ICU

中间两行Warning是分别使用了百度地图的jar包和QQ第三方登录的jar包,其中使用了FloatMath.sqrt()这个方法后,编译时找不到,原因是使用了android 6.0的jar包去编译。通过查看源代码,发现源码里面有这个方法的实现,但反编译SDK中的android.jar时,发现里面没有实现,坑!

之前一直没有使用android 23编译代码,现在项目要兼容6.0,就使用了6.0的编译环境,结果就出现了这样的错。唉,各种坑啊!

解决方案。

在proguard-rules.pro文件中增加如下所示的配置:

-dontwarn com.baidu.**
-dontwarn com.tencent.**

以后遇上这种waring,都可以这样做,-dontwarn是混淆参数,com.xxx是包名,也就是忽略这个包名下面的waring。

参考:gradle build报错:Please correct the above warnings first解决方案

关注我的公众号,轻松了解和学习更多技术
这里写图片描述

发布了242 篇原创文章 · 获赞 776 · 访问量 226万+
展开阅读全文

android studio 混淆后,打包报错!!!

03-01

`` > Exception while processing task java.io.IOException: The same input jar [E:\Work\gv\app\libs\open_sdk_r5509.jar] is specified twice. > at proguard.ConfigurationChecker.checkConflicts(ConfigurationChecker.java:216) > at proguard.ConfigurationChecker.check(ConfigurationChecker.java:83) > at proguard.ProGuard.execute(ProGuard.java:73) > at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074) > at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139) at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115) > at com.android.builder.tasks.Job.runTask(Job.java:48) > at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41) > at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227) > at java.lang.Thread.run(Thread.java:745) > :app:dexAnzhiRelease UP-TO-DATE > :app:validateReleaseSigning > :app:packageAnzhiRelease FAILED > FAILURE: Build failed with an exception. > * What went wrong: > Execution failed for task ':app:packageAnzhiRelease'. > Unable to compute hash of E:\Work\gv\app\build\intermediates\classes-proguard\anzhi\release\classes.jar * Try: > Run with --stacktrace option to get the stack trace. Run with --info or --debug > option to get more log output. > BUILD FAILED > Total time: 18.962 secs ` > ``` 请大神指导,小弟在线求。刚才在网上学习了混淆技巧,把混淆模板复制过去,然后打包报错。 问答

如何解决Unity打包Gradle build failed问题

09-20

问题: CommandInvokationFailure: Gradle build failed. F:/Program Files/Unity/2019.3.0b3/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe -classpath "F:\Program Files\Unity\2019.3.0b3\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease" FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':unityLibrary:packageReleaseResources'. > Could not resolve all files for configuration ':unityLibrary:_internal_aapt2_binary'. > Could not resolve com.android.tools.build:aapt2:3.4.0-5326820. Required by: project :unityLibrary > Could not resolve com.android.tools.build:aapt2:3.4.0-5326820. > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.4.0-5326820/aapt2-3.4.0-5326820.pom'. > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.4.0-5326820/aapt2-3.4.0-5326820.pom'. > Connect to mirrors.opencas.ac.cn:80 [mirrors.opencas.ac.cn/124.16.75.211] failed: Connection timed out: connect > Could not resolve com.android.tools.build:aapt2:3.4.0-5326820. > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/aapt2/3.4.0-5326820/aapt2-3.4.0-5326820.pom'. > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/aapt2/3.4.0-5326820/aapt2-3.4.0-5326820.pom'. > Connect to mirrors.opencas.ac.cn:80 [mirrors.opencas.ac.cn/124.16.75.211] failed: Connection timed out: connect 尝试过论坛里的方法,目前JDK的版本是1.8.0,SDK的版本是26.1.1,之前是25,但是因为报错需要26,所以升级上去了,但是还是没有解决 怀疑是环境变量设置的问题,但是小弟并非计算机专业,没有办法非常系统的debug,麻烦各位大佬帮我看看具体是哪里出现了问题 ![图片说明](https://img-ask.csdn.net/upload/201909/20/1568912455_512805.png)![图片说明](https://img-ask.csdn.net/upload/201909/20/1568912467_242775.png)![图片说明](https://img-ask.csdn.net/upload/201909/20/1568912486_584120.png)![图片说明](https://img-ask.csdn.net/upload/201909/20/1568912494_751240.png)![图片说明](https://img-ask.csdn.net/upload/201909/20/1568912502_553839.png)![图片说明](https://img-ask.csdn.net/upload/201909/20/1568912507_195203.png) 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 代码科技 设计师: Amelia_0503

分享到微信朋友圈

×

扫一扫,手机浏览