Skip to content

Location Credentials Provider is failing #1411

@drayan85

Description

@drayan85

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.2.38 - 1.3.34

Platform (JVM/JS/Native)

JVM (Kotlin)

Operating system and version

Android 13

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.potential-regressionMarking this issue as a potential regression to be checked by team member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions