Подтвердить что ты не робот

Получение предупреждений с помощью Proguard (с внешними библиотеками)

Я включил Proguard, и я пытаюсь создать APK, и я получаю много предупреждений и не знаю, как их решить.

Я использую Retrofit, Jsoup и другие фондовые библиотеки, я получаю следующие предупреждения:

 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.

Здесь моя 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.** { *; }
4b9b3361

Ответ 1

Когда вы используете ProGuard, вы всегда должны разрешать все предупреждения.

Эти предупреждения говорят вам, что библиотеки ссылаются на некоторый код, и для этого нет источников. Это может и не совсем нормально. Это зависит от того, вызвал ли проблемный код.

В этом случае предупреждения для Okio и Retrofit2 могут быть проигнорированы. Пакет java.nio.* недоступен на Android и никогда не будет вызываться. Вы можете смело игнорировать эти предупреждения. Также классы Java 8 не будут использоваться.

Добавьте это в свою конфигурацию ProGuard, он должен исправить вашу проблему:

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

Ответ 2

Страница "Дооснащение" отметила о сборке proguard:

Платформа вызывает Class.forName для типов, которых нет на Android для определения платформы.

-dontnote retrofit2.Platform

Платформа, используемая при работе на виртуальных машинах Java 8. Не будет использоваться во время выполнения.

-dontwarn retrofit2.Platform $Java8

Сохраните информацию о типовом типе для использования при отражении преобразователями и адаптерами.

-keepattributes Подпись

Сохранить объявленные проверенные исключения для использования экземпляром Proxy.

-keepattributes Исключения

проверьте его здесь: http://square.github.io/retrofit/

Ответ 3

В моем случае я не хотел иметь дело с предупреждениями, поэтому я использовал это в proguard-rules.pro

-dontwarn **.**