51

I have enabled Proguard, and i'm trying to build the APK, and i'm getting a lot of warnings and don't know how to solve them .

I'm using Retrofit, Jsoup and other stock libraries, I'm getting the following warnings :

 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.

Here's my 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.** { *; }
1
  • You should add -keep class or dontwarn with okio.Okio as the warning said.
    – user5980999
    Commented Mar 15, 2016 at 12:16

2 Answers 2

122

When you use ProGuard you have to always resolve all warnings.

These warnings tell you that the libraries reference some code and there are no sources for that. That might and might not be ok. It depends if the problematic code ever get called.

In this case warnings for Okio and Retrofit2 can be ignored. Package java.nio.* isn't available on Android and will be never called. You can safely ignore those warnings. Also Java 8 classes won't be used.

Add this to your ProGuard configuration, it should fix your problem:

-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8
2
  • The Android 7 SDK supports Java 8 and java.nio. Is this answer still correct there? (Disclaimer: I know little about Okio, sorry if this is a stupid question). Commented Aug 23, 2016 at 19:57
  • 1
    Yes, it still holds. Android SDK contains some classes from java.nio, but it doesn't contain anything from java.nio.file.
    – Tomik
    Commented Aug 23, 2016 at 22:30
1

Retrofit page has noted about the proguard build:

# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions

check it here: https://web.archive.org/web/20170709124155/http://square.github.io/retrofit/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.