Integrate the Appstore SDK
To learn how to add the Appstore SDK to your project, use this guide.
Add the Appstore SDK to your project
To integrate the Appstore SDK into your Android project, follow the steps below:
- Step 1: Configure Appstore SDK with your public key
- Step 2 (Recommended): Use Maven Central to add the Appstore SDK to your project
- Or Alternative Step 2: Manually add the Appstore SDK to your project library
Step 1: Configure Appstore SDK with your public key
This public key, which is unique per app, establishes a secure communication channel between the Amazon Appstore and your app. When you generate the public key from the Developer Console, Amazon generates a corresponding private key. These public and private keys form a key pair to sign license responses. Through this key pairing, you ensure that the users who install your app are authorized.
To configure your existing app with the public key:
- Log into the Developer Console with your developer account.
- Go to Apps & Services > My Apps. Then click your app. If you don't already have an app, see Submitting Apps to the Amazon Appstore.
-
Create a new version of your app. In the area below your app's name, click Upcoming Version.
Important: The link to the public key appears only when you create a new version or when you create a new app. If you had a new version in progress prior to the release of the Appstore SDK, you must complete your existing version and then create a new version. Only then does the public key link appear. (Alternatively, submit a Contact Us Case regarding your app and request that the Upcoming Version be cancelled.) - Go to the Upload Your App File screen.
- In the Additional information section, click View public key.
-
In the Public Key dialog box that appears, click the AppstoreAuthenticationKey.pem link to download a PEM file. This file contains your public key.
-
Copy the AppstoreAuthenticationKey.pem file. Then paste it into the app/src/main/assets folder of your Android Studio project.
In the Project view, the assets folder is usually in app/src/main/assets. If your app doesn't have an assets folder, you must create one. Then drag your PEM file into it.
Step 2 (Recommended): Use Maven Central to add the Appstore SDK to your project
Integrating and updating the Amazon Appstore SDK in Android Studio is easier with the Amazon SDK release on Maven Central. Maven Central is a repository of build-artifacts. You can integrate those artifacts directly within Android Studio and the Gradle open source build automation system. If you develop your app using Android Studio and Gradle, you can integrate the Amazon Appstore SDK by setting up your app's build.gradle
file. In this way your project will always use the latest version of the SDK.
Follow these instructions:
-
If you haven't done so, log into the Developer Console with your developer account and download the public key for your app.
-
Go back to your Android Studio project. If you already have an older version of the Amazon Appstore SDK in your code, remove the old SDK.
-
In Android Studio, change to the Project view.
-
Expand your app folder and open your app's
build.gradle
file. -
Insert the Amazon Appstore SDK into the dependencies section of your
build.gradle
file as shown below.dependencies { ... implementation 'com.amazon.device:amazon-appstore-sdk:3.+' }
Note: The example above shows you how to get the latest Amazon Appstore SDK with major version 3. You can also define specific versions and/or wildcards. Using wildcards is not a suitable option for a live project because of unforeseen stability issues. However, using wildcards in your version declaration can be useful while debugging or testing your project against the latest version of the Amazon Appstore SDK. Replace any segment of the version number with a
+
to use the latest iteration:// Pull and compile the specific release of the Amazon Appstore SDK implementation 'com.amazon.device:amazon-appstore-sdk:3.0.5' // Pull and compile the latest 3.x release of the Amazon Appstore SDK implementation 'com.amazon.device:amazon-appstore-sdk:3.+' // Pull and compile the latest release of the Amazon Appstore SDK implementation 'com.amazon.device:amazon-appstore-sdk:+'
The next time you build your app, this method imports all the necessary files into your project.
-
Make sure your project's top-level
build.gradle
has the Maven Central repository defined, or add it otherwise:allprojects { repositories { mavenCentral() } dependencies { ... } }
-
Rebuild your project: Build > Rebuild project.
If you follow the above procedure, you don't need to read the next section.
Alternative Step 2: Manually add the Appstore SDK to your project library
Add the amazon-appstore-sdk-[x].jar into your Android project:
-
In Android Studio, change to the Project view.
-
Expand your app folder and select libs. (If you don't have a libs folder, create one). Paste the amazon-appstore-sdk-[x].jar file into this directory.
-
Open your app's build.gradle file and add a dependency on the amazon-appstore-sdk-[x].jar. For example, if the JAR was version 3.0.5, the code would look like this:
dependencies { implementation files('libs/amazon-appstore-sdk-3.0.5.jar') }
Customize the name above based on the amazon-appstore-sdk-[x].jar version you use.
If you have multiple dependencies, instead of referring to a specific JAR, you can reference all JARs more generally like this:
dependencies { ... api fileTree(dir: 'libs', include: ['*.jar']) }
Next steps
You can now use the IAP, DRM, and SSI APIs to leverage the needed functionality in your app. See these topics for more information:
- DRM Overview
- IAP Overview
- Implement Appstore SDK IAP
- Transitioning from IAP v2.0 to the Appstore SDK
- Understanding Simple Sign-in
FAQ
See the FAQ sections in these topics for more details:
Last updated: Mar 15, 2024