Gradle 3.4.1 не может разобрать ответ в Object с помощью Proguard - PullRequest
0 голосов
/ 28 мая 2019

Я только что обновил свой 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>;
}

Мой файл Proguard 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 proguard:

-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>;
}

1 Ответ

1 голос
/ 28 мая 2019

PS: Это нормально работает в режиме отладки или если я запускаю приложение с версией Gradle 3.3.2

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

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

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

...