设置minifyEnabled后,无法生成签名APk

时间:2017-07-16 08:38:36

标签: android apk retrofit android-proguard

我已将Warning:com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry Warning:okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Warning:okio.Okio: can't find referenced class java.nio.file.Files Warning:okio.Okio: can't find referenced class java.nio.file.Path Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption Warning:okio.Okio: can't find referenced class java.nio.file.Path Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption Warning:okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Warning:okio.Okio: can't find referenced class java.nio.file.Path Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption Warning:okio.Okio: can't find referenced class java.nio.file.Path Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption Warning:okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Warning:retrofit2.Platform$Java8: can't find referenced method 'boolean isDefault()' in library class java.lang.reflect.Method Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles$Lookup Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandle Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandle Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles$Lookup Warning:retrofit2.Platform$Java8: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Warning:there were 27 unresolved references to classes or interfaces. 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'. > Job failed, see logs for details 设为true,但之后我无法生成已签名的apk。

显示警告和错误:

{{1}}

现在当我将minifyEnabled设置为false时,它将允许我生成已签名的apk但我想将其设置为true。

我怎样解决这个问题?

2 个答案:

答案 0 :(得分:0)

这是okio和proguard的问题。

关注this link以获取详细说明 但简而言之,您似乎需要将这些行添加到项目中的proguard-rules文件中。

-dontwarn okhttp3.**
-dontwarn okio.**

答案 1 :(得分:0)

在proguard-rules文件中添加以下行:

-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn com.fasterxml.jackson.databind.**

Reference