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 FAILEDFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. java.io.IOException: Please correct the above warnings first.
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

分析:

上面提示编译过程中出现了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.FloatMathWarning: com.tencent.connect.avatar.c: can't find referenced method 'float sqrt(float)' in library class android.util.FloatMathNote: android.support.v4.text.ICUCompatIcs: can't find dynamically referenced class libcore.icu.ICU
  
  
  • 1
  • 2
  • 3
  • 4

中间两行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.**
  
  
  • 1
  • 2

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

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

 

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

           
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值