Android Proguard问题

问题描述 投票:0回答:2

我一直在使用android jetpack,调试工作完全正常,但是一旦我尝试建立启用minify的签名apk,我就面临此问题

java.lang.NoClassDefFoundError: Failed resolution of: Lq0;
    at java.lang.Class.getDeclaredFields(Native Method)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.a(SourceFile:10)
    at c.i.d.k.a(SourceFile:65)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.a(SourceFile:35)
    at c.i.d.k.a(SourceFile:65)
    at retrofit2.converter.gson.GsonConverterFactory.responseBodyConverter(SourceFile:3)
    at retrofit2.Retrofit.nextResponseBodyConverter(SourceFile:6)
    at retrofit2.Retrofit.responseBodyConverter(SourceFile:1)
    at retrofit2.HttpServiceMethod.createResponseConverter(SourceFile:2)
    at retrofit2.HttpServiceMethod.parseAnnotations(SourceFile:15)
    at retrofit2.ServiceMethod.parseAnnotations(SourceFile:5)
    at retrofit2.Retrofit.loadServiceMethod(SourceFile:4)
    at retrofit2.Retrofit$1.invoke(SourceFile:5)
    at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
    at $Proxy2.callUpgradeApi(Unknown Source)
    at c.a.b.b.a.c$a.run(SourceFile:7)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:919)

保护规则如下

-dontnote

-dontskipnonpubliclibraryclasses

-forceprocessing

-optimizationpasses 5

-assumenosideeffects class android.util.Log {
   public static boolean isLoggable(java.lang.String, int);
   public static *** d(...);
   public static *** v(...);
   public static *** i(...);
   public static *** w(...);
   public static *** e(...);
}

-assumenosideeffects class com.highorbit.jobseeker.util.helperUtils.Logger {
   public static *** d(...);
   public static *** e(...);
}

-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-dontwarn javax.annotation.**
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**
-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}
-keepclasseswithmembers interface * {
    @retrofit2.http.* <methods>;
}
-keep class sun.misc.Unsafe { *; }
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

-keepclassmembers enum * { *; }
-keepclassmembers enum * { *; }

-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable

-keep public class * extends java.lang.Exception

-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**


-keep class * extends androidx.fragment.app.Fragment{}

另外,我无法解决的另一件事是,我无法获取崩溃的确切文件名和行号。我已经为crashlytics添加了所有proguard规则,但仍然没有成功

android kotlin proguard android-jetpack
2个回答
0
投票
// all classes in a package -keep class com.example.app.json.** { *; } // or a specific class -keep class com.example.app.json.SpecificClass { *; }

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.