Proguard混淆后Android应用程序崩溃

时间:2014-03-10 05:47:36

标签: android amazon-web-services proguard

我的应用程序在没有Proguard Obfuscation的情况下工作正常。如果我用Proguard Obfuscation导出它然后我安装apk文件,它就会崩溃第一个活动本身。 我在我的应用程序中使用AWS android sdk。

我的Proguard.txt文件是

# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
    native <methods>;
}

# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
   void set*(***);
   *** get*();
}

# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version.  We know about them, and they are safe.
-dontwarn android.support.**


#AWS
-keep class org.apache.commons.logging.**               { *; }
-keep class com.amazonaws.services.sqs.QueueUrlHandler  { *; }
-keep class com.amazonaws.javax.xml.transform.sax.*     { public *; }
-keep class com.amazonaws.javax.xml.stream.**           { *; }
-keep class com.amazonaws.services.**.model.*Exception* { *; }
-keep class org.codehaus.**                             { *; }
-keepattributes Signature,*Annotation*
-keep class com.amazonaws.** { *; }

-dontwarn com.amazonaws.**
-dontwarn javax.xml.stream.events.**
-dontwarn org.codehaus.jackson.**
-dontwarn org.apache.commons.logging.impl.**
-dontwarn org.apache.http.conn.scheme.**

-keep  class com.fasterxml.jackson.**{*;}
-dontwarn  com.fasterxml.jackson.**

我得到的例外是

03-10 11:05:24.552: E/AndroidRuntime(12241): FATAL EXCEPTION: AsyncTask #1
03-10 11:05:24.552: E/AndroidRuntime(12241): Process: com.in.nc.amlooking4.android, PID: 12241
03-10 11:05:24.552: E/AndroidRuntime(12241): java.lang.RuntimeException: An error occured while executing doInBackground()
03-10 11:05:24.552: E/AndroidRuntime(12241):    at android.os.AsyncTask$3.done(AsyncTask.java:300)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at java.lang.Thread.run(Thread.java:841)
03-10 11:05:24.552: E/AndroidRuntime(12241): Caused by: java.lang.NullPointerException
03-10 11:05:24.552: E/AndroidRuntime(12241):    at com.in.nc.amlooking4.android.a.d.<init>(Unknown Source)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at com.in.nc.amlooking4.android.a.b.b(Unknown Source)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at com.in.nc.amlooking4.android.a.b.a(Unknown Source)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at com.in.nc.amlooking4.android.f.a(Unknown Source)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at com.in.nc.amlooking4.android.f.doInBackground(Unknown Source)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at android.os.AsyncTask$2.call(AsyncTask.java:288)
03-10 11:05:24.552: E/AndroidRuntime(12241):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)

问题是什么?

1 个答案:

答案 0 :(得分:1)

正如我在your forum post上提到的,在使用Proguard之前,请确保您的AWSCredentials.properties文件位于主要活动的包中。

如果不起作用,请尝试更改为使用常量类而不是属性文件。