• Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. > java.io.IOException: Please correct the above warnings first.


    最近做项目时遇到这个问题了,就是在打包的时候遇到这个异常,在网上查了很多找到了解决方案如下

    gradle在build混淆后的代码时,会出现如下错误提示:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    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

    1
    2
    3
    4
    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文件中增加如下所示的配置:

    1
    2
    -dontwarn com.baidu.**
    -dontwarn com.tencent.**

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

  • 相关阅读:
    Hibernate(九)HQL查询
    Hibernate(八)多对多映射
    Hibernate(七)一对一映射
    Hibernate(六)一对多映射(多对一)
    Hibernate(五)基本数据类型
    Hibernate(四)结构-基础语义和事务
    Hibernate(三)结构-配置文件-实体映射及配置文件
    Hibernate框架简介(二)基本使用增、删、改、查
    Hibernate生成实体类-手工写法(一)
    Java从零开始学四十(反射简述一)
  • 原文地址:https://www.cnblogs.com/yxgyiwen/p/7692158.html
Copyright © 2020-2023  润新知