Gradle 3.4.1 не может анализировать ответ в Object с помощью Proguard

Я только что обновил свой Gradle до 3.4.1. У меня есть вызов API внутри одного из моих модулей. Я использую модуль внутри приложения:

implementation com.mindvalley.module_login:Module_Login:$rootConfiguration.loginLibraryVersion

Теперь, когда я создаю подписанную сборку с помощью ProGuard, объект имеет значение null, что означает, что модификация не может проанализировать объект.

P.S. : Это отлично работает в режиме отладки или если я запускаю приложение с Gradle версии 3.3.2.

Файл My Retrofit Proguard:

-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions

-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}


-keepattributes Signature, InnerClasses, EnclosingMethod

-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
-keepclassmembers,allowshrinking,allowobfuscation interface * {
    @retrofit2.http.* <methods>;
}

-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

-dontwarn javax.annotation.**

-dontwarn kotlin.Unit

-dontwarn retrofit2.KotlinExtensions

-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>


-dontwarn org.codehaus.mojo.**
-keepattributes *Annotation*

-keepattributes RuntimeVisibleAnnotations
-keepattributes RuntimeInvisibleAnnotations
-keepattributes RuntimeVisibleParameterAnnotations
-keepattributes RuntimeInvisibleParameterAnnotations

-keepattributes EnclosingMethod

-keepclasseswithmembers class * {
    @retrofit2.* <methods>;
}

-keepclasseswithmembers interface * {
    @retrofit2.* <methods>;
}

Мой файл программы OkHttp:

-keepattributes Signature
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**

-dontwarn javax.annotation.**
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

-dontwarn org.codehaus.mojo.animal_sniffer.*

-dontwarn okhttp3.internal.platform.ConscryptPlatform

-dontwarn org.codehaus.mojo.animal_sniffer.*

Мой файл программы GSON:

-keepattributes Signature
-keepattributes EnclosingMethod

-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-dontwarn com.google.gson.internal.UnsafeAllocator

-keepattributes Signature

-keepattributes *Annotation*

-dontwarn sun.misc.**
-keep class com.google.gson.examples.android.model.** { <fields>; }

-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

-keepclassmembers,allowobfuscation class * {
  @com.google.gson.annotations.SerializedName <fields>;
}

person Harsh    schedule 28.05.2019    source источник


Ответы (1)


P.S. : Это отлично работает в режиме отладки или если я запускаю приложение с Gradle версии 3.3.2.

Начиная с версии плагина Gradle 3.4.0, D8 / R8 включен по умолчанию, а обфускация будет выполняться R8 вместо ProGuard.

См. Придерживайтесь обфускации ProGuard, чтобы узнать, как придерживаться Proguard.

См. Android / java: переход / переход с ProGuard на R8? о том, как перейти на R8.

person shizhen    schedule 28.05.2019
comment
Он отлично работает, если я отключу R8 в gradle.properties. При включенном R8 это не удается. Подскажите, пожалуйста, нужно ли нам редактировать наши файлы ProGuard или добавлять что-то еще для R8? - person Harsh; 28.05.2019