2016-03-15 8 views
39

Ich habe Proguard aktiviert, und ich versuche, die APK zu bauen, und ich bekomme viele Warnungen und weiß nicht, wie man sie löst.Warnungen mit Proguard erhalten (mit externen Bibliotheken)

Ich bin mit Retrofit, Jsoup und anderen Lagern Bibliotheken, ich bin die folgenden Warnungen erhalten:

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 
Note: the configuration keeps the entry point 'android.support.v7.widget.FitWindowsLinearLayout { void setOnFitSystemWindowsListener(android.support.v7.widget.FitWindowsViewGroup$OnFitSystemWindowsListener); }', but not the descriptor class 'android.support.v7.widget.FitWindowsViewGroup$OnFitSystemWindowsListener' 
Note: the configuration keeps the entry point 'android.support.v7.widget.RecyclerView { void setAccessibilityDelegateCompat(android.support.v7.widget.RecyclerViewAccessibilityDelegate); }', but not the descriptor class 'android.support.v7.widget.RecyclerViewAccessibilityDelegate' 
Note: the configuration keeps the entry point 'android.support.v7.widget.RecyclerView { void setAdapter(android.support.v7.widget.RecyclerView$Adapter); }', but not the descriptor class 'android.support.v7.widget.RecyclerView$Adapter' 
Note: the configuration keeps the entry point 'android.support.v7.widget.RecyclerView { void setRecyclerListener(android.support.v7.widget.RecyclerView$RecyclerListener); }', but not the descriptor class 'android.support.v7.widget.RecyclerView$RecyclerListener' 
Note: the configuration keeps the entry point 'android.support.v7.widget.RecyclerView { void setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager); }', but not the descriptor class 'android.support.v7.widget.RecyclerView$LayoutManager' 
Note: the configuration keeps the entry point 'android.support.v7.widget.RecyclerView { void setRecycledViewPool(android.support.v7.widget.RecyclerView$RecycledViewPool); }', but not the descriptor class 'android.support.v7.widget.RecyclerView$RecycledViewPool' 
Note: the configuration keeps the entry point 'android.support.v7.widget.RecyclerView { void setViewCacheExtension(android.support.v7.widget.RecyclerView$ViewCacheExtension); }', but not the descriptor class 'android.support.v7.widget.RecyclerView$ViewCacheExtension' 
Warning:there were 22 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. 

Hier ist meine proguard:

-keep class * implements android.os.Parcelable { 
    public static final android.os.Parcelable$Creator *; 
} 

##---------------Begin: proguard configuration for Gson ---------- 
# Gson uses generic type information stored in a class file when working with fields. Proguard 
# removes such information by default, so configure it to keep all of it. 
-keepattributes Signature 


# Gson specific classes 
-keep class com.abohani.tdroms.SharedPreferencesTools { *; } 
#-keep class com.google.gson.stream.** { *; } 


# Application classes that will be serialized/deserialized over Gson 
-keep class com.abohani.tdroms.** { *; } 
+0

Sie sollten -keep Klasse oder dontwarn mit okio.Okio hinzufügen, um die Warnung gesagt. –

Antwort

101

Wenn Sie ProGuard verwenden Sie immer alle Warnungen lösen.

Diese Warnungen weisen darauf hin, dass die Bibliotheken auf einen Code verweisen, und es gibt keine Quellen dafür. Das könnte und könnte nicht in Ordnung sein. Es hängt davon ab, ob der problematische Code jemals aufgerufen wird.

In diesem Fall können Warnungen für Okio und Retrofit2 ignoriert werden. Das Paket java.nio.* ist unter Android nicht verfügbar und wird nie aufgerufen. Sie können diese Warnungen ignorieren. Auch Java 8-Klassen werden nicht verwendet.

Fügen Sie diese auf Ihre ProGuard Konfiguration, sollte es Ihr Problem beheben:

-dontwarn okio.** 
-dontwarn retrofit2.Platform$Java8 
+0

Das Android 7 SDK unterstützt Java 8 und java.nio. Ist diese Antwort dort noch richtig? (Disclaimer: Ich weiß wenig über Okio, tut mir leid, wenn das eine dumme Frage ist). – Blaisorblade

+1

Ja, es gilt immer noch. Das Android SDK enthält einige Klassen aus 'java.nio', enthält jedoch nichts aus' java.nio.file'. – Tomik

0

Retrofit Seite wurde über die proguard Build bemerkt:

Platform ruft Class.forName auf Typen, die nicht existieren auf Android Plattform zu bestimmen.

-dontnote retrofit2.Platform

Plattform verwendet, wenn auf Java 8 VMs. Wird zur Laufzeit nicht verwendet.

-dontwarn retrofit2.Platform $ Java8

generische Typinformationen beibehalten durch Konverter und Adapter Verwendung durch Reflexion für.

-keepattributes Signature

erklärt Retain Ausnahmen für die Verwendung durch einen Proxy-Instanz überprüft.

-keepattributes Ausnahmen

es hier überprüfen: http://square.github.io/retrofit/

Verwandte Themen