Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing proguard rule for transfer util #806

Closed
freszu opened this issue Mar 21, 2019 · 4 comments
Closed

Missing proguard rule for transfer util #806

freszu opened this issue Mar 21, 2019 · 4 comments
Assignees
Labels
feature-request Request a new feature s3 Issues with the AWS Android SDK for Simple Storage Service (S3).

Comments

@freszu
Copy link

freszu commented Mar 21, 2019

Describe the bug
Recently we migrated from aws '2.6.30' to '2.12.2' since then the upload is failing on obfuscated version of our app(checked with 2.12.5 as well and problem still exists).

We resolved that by adding

-keep class com.amazonaws.mobileconnectors.s3.transferutility.TransferNetworkConnectionType {*;}

to our proguard setup.
To Reproduce
Create obfuscated version of the app and try to upload anything using transfer utility
Which AWS service(s) are affected?

Expected behavior
Upload should be successful

Environment Information (please complete the following information):

  • AWS Android SDK Version: 2.12.2, 2.12.5
  • Any device

Additional context
Original stack trace:

 Critical error, Aws upload failure for uploads/xx.jpg
 java.lang.AssertionError: java.lang.NoSuchFieldException: ANY
2019-03-21 12:09:09.522 14389-14523/x.x E/w:     at com.google.gson.b.a.n$a.<init>(TypeAdapters.java:792)
     at com.google.gson.b.a.n$24.create(TypeAdapters.java:818)
     at com.google.gson.f.a(Gson.java:458)
     at com.google.gson.b.a.i.a(ReflectiveTypeAdapterFactory.java:117)
     at com.google.gson.b.a.i.a(ReflectiveTypeAdapterFactory.java:166)
     at com.google.gson.b.a.i.create(ReflectiveTypeAdapterFactory.java:102)
     at com.google.gson.f.a(Gson.java:458)
     at com.google.gson.f.a(Gson.java:696)
     at com.google.gson.f.a(Gson.java:683)
     at com.google.gson.f.b(Gson.java:638)
     at com.google.gson.f.b(Gson.java:618)
     at com.amazonaws.mobileconnectors.s3.transferutility.TransferDBUtil.b(TransferDBUtil.java:806)
     at com.amazonaws.mobileconnectors.s3.transferutility.TransferDBUtil.a(TransferDBUtil.java:139)
     at com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility.a(TransferUtility.java:549)
     at com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility.a(TransferUtility.java:572)
...
@freszu
Copy link
Author

freszu commented Mar 21, 2019

Also is there any reason for which consumerProguardFiles are not provided with the library and developers needs to add them manually?
(see consumerProguardFiles :
https://developer.android.com/studio/projects/android-library#Considerations)

@minbi
Copy link
Contributor

minbi commented Mar 21, 2019

Hi @freszu ,

The S3 module is distributed as a JAR and not an AAR. We are considering transitioning, but evaluating if this would break any of our customers.

@minbi minbi added feature-request Request a new feature s3 Issues with the AWS Android SDK for Simple Storage Service (S3). labels Mar 21, 2019
@mutablealligator mutablealligator self-assigned this Apr 4, 2019
@raphkim raphkim mentioned this issue Aug 15, 2019
@raphkim raphkim self-assigned this Aug 15, 2019
@raphkim
Copy link
Contributor

raphkim commented Aug 30, 2019

Hi @freszu,

I wasn't able to reproduce the exact bug, but I think I have a potential fix for your issue. Would it be possible to test your app with this code base to see if your issue is resolved?

If not, would you be able to provide us with more information regarding what proguard rules you used to obfuscate your code? For example, did you use any third-party library for obfuscation?

Thank you.

@freszu
Copy link
Author

freszu commented Sep 17, 2019

Hi @raphkim sorry for coming with an answer so late.

So i managed to make a local build with your changes and use generated jars instead.
The mentioned enum was still removed upon obfuscation and i experienced the same error until i reapplied the rule mentioned in first post. It seems that R8/proguard thinks that this enum is never used and so it's removed upon obfuscation/something is renamed.
This is the updated stack trace:

java.lang.AssertionError: java.lang.NoSuchFieldException: ANY
    at com.google.gson.v.n.n$k0.<init>(TypeAdapters.java:792)
    at com.google.gson.v.n.n$w.create(TypeAdapters.java:818)
    at com.google.gson.f.a(Gson.java:458)
    at com.google.gson.v.n.i.a(ReflectiveTypeAdapterFactory.java:117)
    at com.google.gson.v.n.i.a(ReflectiveTypeAdapterFactory.java:166)
    at com.google.gson.v.n.i.create(ReflectiveTypeAdapterFactory.java:102)
    at com.google.gson.f.a(Gson.java:458)
    at com.google.gson.f.a(Gson.java:696)
    at com.google.gson.f.a(Gson.java:683)
    at com.google.gson.f.a(Gson.java:638)
    at com.google.gson.f.a(Gson.java:618)
    at com.amazonaws.mobileconnectors.s3.transferutility.TransferDBUtil.b(TransferDBUtil.java:806)
    at com.amazonaws.mobileconnectors.s3.transferutility.TransferDBUtil.a(TransferDBUtil.java:139)
    at com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility.a(TransferUtility.java:571)
    at com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility.a(TransferUtility.java:597)

About our setup we are not using anything extraordinary and recently made switch from proguard to r8 but the problem still occurs. We applied all the rules mentioned in the https://github.com/aws-amplify/aws-sdk-android/blob/master/Proguard.md + the one mentioned in first post to overcome the issue with missing enum. Release build is configured with minifyEnabled true

Other people ran into the same problem in the past but issue was closed: #704

@mutablealligator mutablealligator removed their assignment Dec 16, 2019
raphkim added a commit that referenced this issue Oct 29, 2020
raphkim added a commit that referenced this issue Oct 29, 2020
raphkim added a commit to raphkim/aws-sdk-android that referenced this issue Nov 12, 2020
raphkim added a commit that referenced this issue Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request a new feature s3 Issues with the AWS Android SDK for Simple Storage Service (S3).
Projects
None yet
Development

No branches or pull requests

5 participants