Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard Aws s3 issue

Having a real issue trying to implement proguard for amazon s3 it keeps on crashing on loading the application at line 29 which is

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

This is the stack trace of the error and not sure what it means to be honest any way getting a better stacktrace or any suggestions on how to fix it?

  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)

Here is my 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>;
}
like image 692
user1408682 Avatar asked Mar 19 '23 18:03

user1408682


2 Answers

sorry that you're having trouble. It looks like you haven't tried using the Proguard config provided in the AWS samples. It might still not fix your problem, but it would be worthwhile to give it a try. If it still doesn't work we can try seeing where to go from there, and at least it would likely give you a better stack trace. You can find it here: https://github.com/awslabs/aws-sdk-android-samples

And the proguard config is..

# 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

Please let me know if it still gives you trouble after using this.

like image 93
Richard Fung Avatar answered Mar 24 '23 17:03

Richard Fung


Thanks for everyones help it was a combination of everyone

-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.**
like image 34
user1408682 Avatar answered Mar 24 '23 18:03

user1408682