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

Location Credentials Provider is failing #1411

Open
1 task done
drayan85 opened this issue Sep 19, 2024 · 0 comments
Open
1 task done

Location Credentials Provider is failing #1411

drayan85 opened this issue Sep 19, 2024 · 0 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. potential-regression Marking this issue as a potential regression to be checked by team member

Comments

@drayan85
Copy link

drayan85 commented Sep 19, 2024

Describe the bug

We are using Cognito pool ID in our Android Project to use the AWS location service.

When we try to create the LocationCredentialProvider (AuthHelper(context).authenticateWithCognitoIdentityPool(xxxx)) it is failing after 1.2.39 -> 1.3.34 with the following error:
java.lang.NoClassDefFoundError: aws.sdk.kotlin.services.cognitoidentity.endpoints.internal.PartitionsKt

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected behavior

It should successfully return the LocationCredentialsProvider object

Current behavior

Throwing Exception:

java.lang.NoSuchMethodError: No direct method <init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;ILkotlin/jvm/internal/DefaultConstructorMarker;)
V in class Laws/sdk/kotlin/runtime/endpoint/functions/PartitionConfig; or its super classes (declaration of 'aws.sdk.kotlin.runtime.endpoint.functions.PartitionConfig' 
appears in /data/app/~~S8m3JjDNTe7asB6VD3qQwA==/com.android-aws-location-A2tHD-m82ib5570DnPQ5Eg==/base.apk!classes20.dex)

Steps to Reproduce

Location demo app was working as expected when aws.sdk.kotlin:location => 1.2.38 and just updating this to 1.2.39 in the gradle configuration started get this exception.
FYI, We are not forcing the OKHTTP3 library to downgrade (Some other issue mentioning that this exception is occurred when they force downgrade to OkHttp3 to 4.x verion )

Possible Solution

Currently we are downgraded the aws.sdk.kotlin:location to 1.2.38 and working as expected.

Exception started inside the LocationCredentialsProvider -> val getIdResponse = cognitoIdentityClient?.getId(GetIdRequest { this.identityPoolId = identityPoolId })

    private suspend fun generateCredentials(region: String, identityPoolId: String) {
        if (cognitoIdentityClient == null) {
            cognitoIdentityClient = generateCognitoIdentityClient(region)
        }
        try {
            val getIdResponse = cognitoIdentityClient?.getId(GetIdRequest { this.identityPoolId = identityPoolId })
            val identityId =
                getIdResponse?.identityId ?: throw Exception("Failed to get identity ID")
            if (identityId.isNotEmpty()) {
                val getCredentialsResponse =
                    cognitoIdentityClient?.getCredentialsForIdentity(GetCredentialsForIdentityRequest {
                        this.identityId = identityId
                    })

                val credentials = getCredentialsResponse?.credentials
                    ?: throw Exception("Failed to get credentials")
                if (credentials.accessKeyId == null || credentials.secretKey == null || credentials.sessionToken == null) throw Exception(
                    "Credentials generation failed"
                )
                cognitoCredentialsProvider = CognitoCredentialsProvider(
                    context,
                    identityId,
                    credentials
                )
                locationClient = null
            }
        } catch (e: Exception) {
            throw Exception("Credentials generation failed")
        }
    }

Context

We are far away from the latest of the library in our production app and also concern about using not stable OkHttp3 (5.0.0-alpha.14) library which will override by the AWS library (transient dependency) in our production app

AWS SDK for Kotlin version

1.238 - 1.3.34

Platform (JVM/JS/Native)

JVM (Kotlin)

Operating system and version

Android 13

@drayan85 drayan85 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 19, 2024
@github-actions github-actions bot added the potential-regression Marking this issue as a potential regression to be checked by team member label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. potential-regression Marking this issue as a potential regression to be checked by team member
Projects
None yet
Development

No branches or pull requests

1 participant