2017-07-16 79 views
1

我已啓用minifyEnabled爲true,但在此之後,我無法生成已簽名的apk。設置後無法生成簽名APk minifyEnabled true

它顯示警告和錯誤:

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 

現在,當我已經設置minifyEnabled爲false那麼它會讓我產生簽署的apk,但我想將它設置爲true。

我該如何解決這個問題?

+0

請參閱爲你是如何配置你的Proguard的,這就是如果任何庫導致的問題。檢查此https://stackoverflow.com/questions/33589318/error-building-apk-when-minifyenabled-true –

回答

0

這是okio和proguard的問題。

按照this link的詳細解釋 但總之,似乎你需要將這些行添加到項目中的proguard-rules文件。

-dontwarn okhttp3.** 
-dontwarn okio.** 
+0

也看到這篇文章https://stackoverflow.com/questions/36737073/how-to-fix-warning-安卓eclipse-proguard-rul/37745414#37745414 – ApriOri

+0

我已經定義了: '-keep class com.fasterxml.jackson.databind.ObjectMapper { public ; 保護; } -keep class com.fasterxml.jackson.databind.ObjectWriter { public ** writeValueAsString(**); } -keepnames class com.fasterxml.jackson。** {*; } -dontwarn com.fasterxml.jackson.databind。** -dontwarn okhttp3。** -dontwarn奧基奧。** -dontwarn retrofit2.Platform $ Java8' 但畢竟這解決了所有錯誤,但應用程序不能調用任何函數 – deepak

1

在proguard相關規則文件添加這些行:

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

Reference

+0

我已經定義了: '-keep class com.fasterxml.jackson.databind.ObjectMapper { public ; 保護; } -keep class com.fasterxml.jackson.databind.ObjectWriter { public ** writeValueAsString(**); } -keepnames class com.fasterxml.jackson。** {*; } -dontwarn com.fasterxml.jackson.databind。** -dontwarn okhttp3。** -dontwarn奧基奧。** -dontwarn retrofit2.Platform $ Java8' 但畢竟這解決了所有錯誤,但應用程序不能調用任何函數。 – deepak

+0

@deepak https://stackoverflow.com/a/11249755/6244429 –

+0

仍然無法正常工作! – deepak

相關問題