簡體   English   中英

使用Proguard運行簽名的APK時出錯

[英]Error when running signed APK with Proguard

在啟用Proguard的情況下啟動簽名的APK版本時,我的應用程序崩潰了。 請注意,在常規調試模式下,應用程序不會崩潰。

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 

現在,如果我猜得出來,我會說Proguard混淆了一些本不應該的類。 那么,如何進行調試呢?

這是我的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.** { *; }

那么可能是什么原因造成的呢?

顯然問題出在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