简体   繁体   中英

Error when running signed APK with Proguard

My app is crashing upon launching the signed apk version with Proguard enabled. Note that in regular debug mode, the app does not crash.

FATAL EXCEPTION: AsyncTask #1
Process: orbyt.horizon, PID: 21671
       java.lang.RuntimeException: An error occurred while executing doInBackground()
           at android.os.AsyncTask$3.done(AsyncTask.java:309)
           at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
           at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
           at java.util.concurrent.FutureTask.run(FutureTask.java:242)
           at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
           at java.lang.Thread.run(Thread.java:818)
        Caused by: java.lang.NoSuchFieldError
           at libcore.reflect.AnnotationAccess.decodeValue(AnnotationAccess.java:688)
           at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:663)
           at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:641)
           at libcore.reflect.AnnotationAccess.getDeclaredAnnotation(AnnotationAccess.java:171)
           at libcore.reflect.AnnotationAccess.getAnnotation(AnnotationAccess.java:72)
           at java.lang.Class.getAnnotation(Class.java:359)
           ... 
        Caused by: java.lang.NoSuchFieldException: No field LINK in class La/a/a/c/a/i; (declaration of 'a.a.a.c.a.i' appears in /data/app/orbyt.horizon-1/base.apk)
           at java.lang.Class.getDeclaredField(Native Method)
           at libcore.reflect.AnnotationAccess.decodeValue(AnnotationAccess.java:685)
           at 

Now, if I were to guess I would say that Proguard is obfuscating a few classes that it shouldnt be. So how do you go about debugging this?

Here is my proguard-rules.pro :

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

# Retrofit 2.X
## https://square.github.io/retrofit/ ##

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

# Butterknife

-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }
-keepclasseswithmembernames class * {
    @butterknife.* <fields>;
}
-keepclasseswithmembernames class * {
    @butterknife.* <methods>;
}

# Glide specific rules #
# https://github.com/bumptech/glide

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
    **[] $VALUES;
    public *;
}


## Retrolambda specific rules ##

# as per official recommendation: https://github.com/evant/gradle-retrolambda#proguard
-dontwarn java.lang.invoke.*

# OkHttp
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**


#JodaTime
# These aren't necessary if including joda-convert, but
# most people aren't, so it's helpful to include it.
-dontwarn org.joda.convert.FromString
-dontwarn org.joda.convert.ToString

#twitter4j
-dontwarn twitter4j.**
-keep class twitter4j.** { *; }

#google
-dontwarn com.google.**

#okio
-dontwarn com.squareup.**
-dontwarn okio.**

#misc
-dontwarn com.google.code.**
-dontwarn oauth.signpost.**
-dontwarn twitter4j.**
-dontwarn javax.management.**
-dontwarn javax.xml.**
-dontwarn org.apache.**
-dontwarn org.slf4j.**
-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry
-optimizations !class/unboxing/enum
-keep  class com.fasterxml.jackson.annotation.** {*;}
-keep  class com.fasterxml.jackson.core.** {*;}
-keep  class com.fasterxml.jackson.databind.** {*;}
-keep class libcore.** { *; }

So what might be causing this?

Apparently the issue was with JRAW , adding the following lines to my proguard-rules.pro file seems to have fixed the issue:

#jraw
-dontwarn net.dean.**
-keep class net.dean.** {*;}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM