Proguard Aws s3问题

时间:2014-08-13 11:08:22

标签: android amazon-web-services amazon-s3 proguard

有一个真正的问题试图为amazon s3实现proguard它继续崩溃加载应用程序在第29行

  s3Client = new AmazonS3Client(new BasicAWSCredentials(
            Constants.ACCESS_KEY_ID, Constants.SECRET_KEY));

这是错误的堆栈跟踪,并且不确定任何方式获得更好的堆栈跟踪或任何有关如何修复它的建议都意味着什么?

  Process: com.closr.closr, PID: 24517
  java.lang.NoSuchFieldError: PUBLIC_ONLY
        at java.lang.Class.getDeclaredAnnotation(Native Method)
        at java.lang.Class.getAnnotation(Class.java:290)
        at com.b.a.c.f.u$a.<clinit>(VisibilityChecker.java:172)
        at com.b.a.c.r.<clinit>(ObjectMapper.java:195)
        at com.a.l.a.a.<clinit>(Unknown Source)
        at com.a.e.a.c.loadfrom(Unknown Source)
        at com.a.e.a.c.load(Unknown Source)
        at com.a.e.a.c$a.<clinit>(Unknown Source)
        at com.a.o.getServiceName(Unknown Source)
        at com.a.c.computeServiceName(Unknown Source)
        at com.a.c.getServiceNameIntern(Unknown Source)
        at com.a.c.configSigner(Unknown Source)
        at com.a.c.setEndpoint(Unknown Source)
        at com.a.j.a.a.init(Unknown Source)
        at com.a.j.a.a.<init>(Unknown Source)
        at com.a.j.a.a.<init>(Unknown Source)
        at com.closr.closr.MainApplication.onCreate(MainApplication.java:29)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4328)
        at android.app.ActivityThread.access$1500(ActivityThread.java:135)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5001)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
        at dalvik.system.NativeStart.main(Native Method)

这是我的proguard.cfg

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-dontoptimize
-dontpreverify
-dontwarn
-keepattributes *Annotation*,Exceptions,InnerClasses,Signature,Deprecated,       SourceFile,LineNumberTable,*Annotation*,EnclosingMethod

-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-keep public class org.apache.commons.** { *; }
-keep public class * extends android.app.Application
-keepnames class org.codehaus.jackson.** { *; }
-keepclassmembers class com.amazonaws.** { *; }

-keepclassmembers class com.closr.closr.** {
public static <fields>;
}

-keepclasseswithmembernames class * {
native <methods>;
}
-keepclassmembers public class * extends android.view.View {
 void set*(***);
 *** get*();
}
-keepclassmembers class * extends android.app.Activity {
  public void *(android.view.View);
}
-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>;
}

3 个答案:

答案 0 :(得分:5)

抱歉,你遇到了麻烦。看起来您还没有尝试使用AWS示例中提供的Proguard配置。它可能仍然无法解决您的问题,但值得尝试一下。如果它仍然无法工作,我们可以尝试从那里去哪里,至少它可能会给你一个更好的堆栈跟踪。你可以在这里找到它: https://github.com/awslabs/aws-sdk-android-samples

而proguard配置是..

# These options are the minimal options for a functioning application
# using Proguard and the AWS SDK for Android

-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 com.amazonaws.internal.**                                   { *; }
-keep class org.codehaus.**                             { *; }
-keep class org.joda.time.tz.Provider                    { *; }
-keep class org.joda.time.tz.NameProvider                { *; }
-keepattributes Signature,*Annotation*,EnclosingMethod
-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class com.amazonaws.** { *; }

-dontwarn com.fasterxml.jackson.databind.**
-dontwarn javax.xml.stream.events.**
-dontwarn org.codehaus.jackson.**
-dontwarn org.apache.commons.logging.impl.**
-dontwarn org.apache.http.conn.scheme.**
-dontwarn org.apache.http.annotation.**
-dontwarn org.ietf.jgss.**
-dontwarn org.joda.convert.**
-dontwarn org.w3c.dom.bootstrap.**

#SDK split into multiple jars so certain classes may be referenced but not used
-dontwarn com.amazonaws.services.s3.**
-dontwarn com.amazonaws.services.sqs.**

-dontnote com.amazonaws.services.sqs.QueueUrlHandler

如果在使用后仍然给您带来麻烦,请告诉我。

答案 1 :(得分:1)

感谢大家的帮助,这是每个人的组合

-dontoptimize
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-ignorewarnings
-keepdirectories
-dontnote
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
                SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-libraryjars C:/Users/Hobbs/Closr/Closr/libs/aws-android-sdk-1.7.1.1.jar

-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-keep public class org.apache.commons.** { *; }
-keep public class com.nostra13.universalimageloader.** { *; }
-keep public class uk.co.senab.actionbarpulltorefresh.** { *; }
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.content.Context
-keep public class * extends android.app.Activity
-keep public class * extends android.support.v4.app.Activity
-keep public class * extends android.app.Fragment
-keep public class * extends android.support.v4.app.Fragment

-keep class com.google.inject.** { *; }
-keep class com.facebook.** { *; }
-keep class android.os.** { *; }
-keep class com.google.android.gms.maps.** { *; }
-keep class com.google.android.gms.auth.** { *; }
-keep class com.google.android.gms.common.** { *; }
-keep class com.google.android.gms.location.** { *; }
-keep class com.google.android.gms.gcm.** { *; }
-keep class com.google.android.gms.internal.** { *; }
-keep class com.google.android.finsky.utils.** { *; }
-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.**                             { *; }
-keep class javax.inject.** { *; }
-keep class javax.annotation.** { *; }
-keep class com.amazonaws.** { *; }
-keep class org.joda.convert.*                          { *; }
-keepnames class com.fasterxml.jackson.**               { *; }

-keep class com.closr.closr.** { *; }
-keep interface com.closr.closr.** { *; }

-keepclassmembers class com.closr.closr.** {
    public static <fields>;
}

-keepclasseswithmembernames class * {
    native <methods>;
}
-keepclassmembers public class * extends android.view.View {
   void set*(***);
   *** get*();
}
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}
-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>;
}


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

答案 2 :(得分:0)

尝试添加此项(根据您使用的库)。

-libraryjars C:/workspace/3rd-libs/aws-android-sdk-1.5.0/lib/aws-android-sdk-1.5.0-core.jar
-libraryjars C:/workspace/3rd-libs/aws-android-sdk-1.5.0/lib/aws-android-sdk-1.5.0-s3.jar
-libraryjars C:/workspace/3rd-libs/aws-android-sdk-1.5.0/lib/aws-android-sdk-1.5.0-sdb.jar

-keep class com.amazonaws.** { *; }

-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*

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