How to integrate AWS Mobile SDK into Android App

Amazon provides AWS Mobile SDK with JAVA APIs for various Amazon Services (including Amazon Cognito, AWS Lambda, Amazon S3, Amazon Kinesis, Amazon DynamoDB, Amazon Pinpoint…) so that we can build high quality mobile apps quickly and easily. In this tutorial, we’re gonna look at how to integrate AWS Mobile SDK into an Android App.

I. Technology

– Android Studio 2.x
– AWS Mobile SDK Client 2.6.7

II. Step by Step

1. Set Up Backend
1.1 Sign up for the AWS Free Tier

Go to https://aws.amazon.com/free/:

integrate-aws-mobile-sdk-android-app-sign-up

Choose Create a free Account.

Follow the instructions on the screen for sign up.
-> AWS will notify you by email when your account is active and available for you to use.

1.2 Create a Mobile Hub project

– Go to https://console.aws.amazon.com/mobilehub/, then click on Create button:

integrate-aws-mobile-sdk-android-app-create-mobile-hub-project

– Enter project name, then click on Next:

integrate-aws-mobile-sdk-android-app-create-mobile-hub-project-name

– Select Platform, then click on Add:

integrate-aws-mobile-sdk-android-app-create-mobile-hub-project-platform

– Download Cloud Config file (awsconfiguration.json) to your PC:

integrate-aws-mobile-sdk-android-app-create-mobile-hub-project-download-config

After finishing these step, you can see your project in Amazon Console – Mobile Hub:

integrate-aws-mobile-sdk-android-app-result-console

2. Connect to Backend
2.1 Add Cloud Config file

Place awsconfiguration.json file in app/src/main/res/raw:

integrate-aws-mobile-sdk-android-app-add-config-file

2.2 Set permission

Open AndroidManifest.xml, add:

2.3 Add dependencies

These libraries enable basic AWS functions, like credentials, and analytics. Open app/build.gradle, add:

2.4 Establish a connection with AWS Mobile

In main or startup activity, add code to onCreate method:

Now your app can interact with the AWS services.

Run App in Android Studio, you should see log in Android logcat:

By JavaSampleApproach | January 23, 2018.

Last updated on July 13, 2018.


Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*