2016-03-15 14 views
39

Po włączeniu programu Proguard próbuję utworzyć pakiet APK i otrzymuję wiele ostrzeżeń i nie wiem, jak je rozwiązać.Uzyskiwanie ostrzeżeń za pomocą programu Proguard (z bibliotekami zewnętrznymi)

Używam modernizowanych Jsoup i innych bibliotek zdjęcia, Dostaję następujące ostrzeżenia:

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. 

Oto mój 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

Należy dodać -Trzymaj klasę lub dontwarn z okio.Okio jako ostrzeżenie powiedział. –

Odpowiedz

101

Podczas korzystania ProGuard trzeba zawsze rozwiązać wszystkie ostrzeżenia.

Ostrzeżenia te informują, że biblioteki odwołują się do pewnych kodów i nie ma na to żadnych źródeł. To może i nie będzie w porządku. To zależy, czy problematyczny kod zostanie kiedykolwiek wywołany.

W tym przypadku ostrzeżenia dotyczące Okio i Retrofit2 można zignorować. Pakiet java.nio.* nie jest dostępny na Androida i nigdy nie zostanie wywołany. Możesz bezpiecznie zignorować te ostrzeżenia. Również klasy Java 8 nie będą używane.

Dodaj to do swojej konfiguracji PROGUARD, powinno rozwiązać problem:

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

Zestaw SDK dla systemu Android 7 obsługuje język Java 8 i java.nio. Czy ta odpowiedź jest nadal poprawna? (Zrzeczenie się: Wiem niewiele o Okio, przepraszam, jeśli to jest głupie pytanie). – Blaisorblade

+1

Tak, nadal trzyma. Android SDK zawiera niektóre klasy z 'java.nio', ale nie zawiera niczego z' java.nio.file'. – Tomik

0

strona Modernizacja zauważył o budowie PROGUARD: Połączenia

Platforma Class.forName na typy, które nie istnieją na Androida, aby określić platformę.

-dontnote retrofit2.Platform

Platform wykorzystywane podczas pracy na maszynach wirtualnych Java 8. Nie będą używane w czasie wykonywania.

-dontwarn retrofit2.Platform $ Java8

Zachować ogólne informacje typu dla wykorzystania przez odbicia przez przetwornice i adapterów.

-keepattributes podpis

zachować deklarowanej sprawdzane wyjątki dla stosowania przez instancję Proxy.

-keepattributes Wyjątki

sprawdzić tutaj: http://square.github.io/retrofit/

Powiązane problemy