0

I am trying to connect my andoid app to dynamo db for CRUD operation when I click on any button it throws, "Unforutunately app stopped working" from my android device with following log at backend[log cat]

Process: com.connect.dynamodb.connecttodynamodb, PID: 16283 java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) Caused by: java.lang.NoSuchFieldError: com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.endpointPrefix at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.init(AmazonDynamoDBClient.java:460) at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.(AmazonDynamoDBClient.java:444) at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.(AmazonDynamoDBClient.java:392) at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.(AmazonDynamoDBClient.java:361)

I created identity pool,account id,auth user and unauth user roles Configurations done are as follows for Cognito

Try 1 :

> CognitoCachingCredentialsProvider credentials = new
> CognitoCachingCredentialsProvider(context,
>                 "accountId",
>                 Constants.IDENTITY_POOL_ID,
>                 "Unauth_Role",
>                 "Auth_Role",
>                 Regions.US_EAST_1);
>         ddb = new AmazonDynamoDBClient(credentials);
>         ddb.setRegion(Region.getRegion(Regions.US_WEST_2));

Try 2:

    CognitoCachingCredentialsProvider credentials = new CognitoCachingCredentialsProvider(
            context,
            "IDENTITY_POOL_ID",
            Regions.US_EAST_1);

    ddb = new AmazonDynamoDBClient(credentials);
    ddb.setRegion(Region.getRegion(Regions.US_WEST_2));
}

Both tries are not working .Any help would be appreciated.I am referring following link.

Ref : https://github.com/awslabs/aws-sdk-android-samples/blob/master/DynamoDBMapper_UserPreference_Cognito/

1 Answer 1

2

I fixed this issue by adding

> compile 'com.amazonaws:aws-android-sdk-core:2.2.+'
> compile 'com.amazonaws:aws-android-sdk-s3:2.2.+'
> compile 'com.amazonaws:aws-android-sdk-ddb:2.2.+'

and adding aws-android-sdk-ddb-mapper-2.4.7.jar to lib folder and setting the region to Regions.AP_SOUTH_1, where I have created the identity pool.

Sign up to request clarification or add additional context in comments.

4 Comments

compile 'com.amazonaws:aws-android-sdk-ddb-mapper:2.2.+' is also available
Yes Donkon I used it inside the lib folder.
what I mean is: You don't need to have the jar, the artifact is also available through maven just like the core, s3, and ddb
Sorry Donkon I got it at first only but forgot to edit the comment.Yes I will try to add dependency in gradle file and remove the jar in lib .Thnx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.