简体   繁体   English

使用Proguard运行签名的APK时出错

[英]Error when running signed APK with Proguard

My app is crashing upon launching the signed apk version with Proguard enabled. 在启用Proguard的情况下启动签名的APK版本时,我的应用程序崩溃了。 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. 现在,如果我猜得出来,我会说Proguard混淆了一些本不应该的类。 So how do you go about debugging this? 那么,如何进行调试呢?

Here is my proguard-rules.pro : 这是我的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上 ,在我的proguard-rules.pro文件中添加了以下几行似乎已解决了该问题:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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