错误:任务执行失败:app:transformClassesAndResourcesWithProguardForRelease

时间:2016-10-19 09:36:48

标签: android proguard android-proguard

我在构建签名的apk文件时遇到以下异常(如果我只是在发布中构建应用程序,这里没有错误):

Information:Gradle tasks [:api:assemble, :app:assembleRelease]
Warning:Ignoring Android API artifact com.google.android:android:2.2.1 for debug
Warning:Ignoring Android API artifact com.google.android:android:2.2.1 for release
Warning:Ignoring Android API artifact com.google.android:android:2.2.1 for staging
Warning:com.viewpagerindicator.LinePageIndicator: can't find referenced method 'float ceil(float)' in library class android.util.FloatMath
Warning:there were 1 unresolved references to library class members.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.
Information:BUILD FAILED
Information:Total time: 26.173 secs
Information:1 error
Information:6 warnings

这里是gradle log:

Warning: there were 21 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 1 unresolved references to library class members.
         You probably need to update the library versions.
         (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.

我所做的是,我更改proguard-rules.pro文件,以修复导致包裹的异常。我在stackoverflow中找到了答案..

这是它的外观:

-keep class com.zzoome.android.Views.TagGroup.**
-dontwarn com.zzoome.android.Views.TagGroup.**

-keepclassmembers class * implements android.os.Parcelable {
    static ** CREATOR;
}

2 个答案:

答案 0 :(得分:1)

我改变了proguard-rules:

-keep class com.zzoome.android.Views.TagGroup { *; }
-dontwarn com.zzoome.android.Views.TagGroup
-dontwarn com.google.**
-dontwarn com.viewpagerindicator.LinePageIndicator

-keepclassmembers class * implements android.os.Parcelable {
    static ** CREATOR;
}

答案 1 :(得分:-1)

将这些添加到您的proguard规则文件

-dontwarn okio.**

-dontwarn com.google.**

同样添加所有库。