3

Gradle

implementation platform('software.amazon.awssdk:bom:2.17.119')
implementation 'software.amazon.awssdk:s3'

Code Used To get Presigned Url

public static URL getPresignedUrl(String bucketName, String keyName ) {
    PresignedGetObjectRequest presignedGetObjectRequest = null;
    try {
        AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create
                (AwsBasicCredentials.create(Access Key, Secret Key));


        S3Presigner preSigner = S3Presigner.builder()
                .credentialsProvider(credentialsProvider)
                .region(Region.US_WEST_2).build();
        GetObjectRequest getObjectRequest =
                GetObjectRequest.builder()
                        .bucket(bucketName)
                        .key(keyName)
                        .build();

        GetObjectPresignRequest getObjectPresignRequest = null;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            getObjectPresignRequest = GetObjectPresignRequest.builder()
                    .signatureDuration(Duration.ofDays(1))
                    .getObjectRequest(getObjectRequest)
                    .build();
        }

        // Generate the presigned request
         presignedGetObjectRequest =
                 preSigner.presignGetObject(getObjectPresignRequest);
    } catch (Exception e) {
        e.getStackTrace();
    }
    return  presignedGetObjectRequest.url();
}

App working fine if the fire OS version is greater than or equal 7.x.x Crashes on fire OS version 5.x.x

Crashing on the line S3Presigner preSigner = S3Presigner.builder()

Crash Log

Need help

sRahul0805
  • 31
  • 2

1 Answers1

-1

Without exact knowledge about the versions it's hard to spot the reason directly.

But you can try it by yourself by separating the concatenated statements:
Currently:

        S3Presigner preSigner = S3Presigner.builder()
                .credentialsProvider(credentialsProvider)
                .region(Region.US_WEST_2).build();

New:

        S3Presigner preSigner = S3Presigner.builder();
        preSigner = preSigner.credentialsProvider(credentialsProvider);
        preSigner = preSigner.region(Region.US_WEST_2):
        preSigner = preSigner.build();

I'm neither firm with Java nor with the Fire OS API, so it's quite possible that my code wouldn't work even on the never Fire OS versions and you had to change a bit.
Nevertheless I think you can get the idea to disentangle all statements to see which part of causing the problem.
After knowing this you can look if the corresponding function is perhaps missing in Fire OS 5 or if you have to change the parameters perhaps.

David
  • 5,882
  • 3
  • 33
  • 44