Step 1: Use the necessary assets
First, gather all the necessary assets for your project. Download and unzip the following:- DRM Sample App - Part of the Appstore SDK
- Appstore SDK - See SDKs and samples
- Amazon App Tester (on your Fire device) - Download the App Tester from here
AppstoreAuthenticationKey.pem file, but you can download this during Step 3 of the tutorial.
Additionally, you will need the following:
- Android Studio
- Fire TV or Fire tablet device
Step 2: Add the Appstore SDK JAR to the sample app
The Appstore SDK JAR isn’t automatically bundled into the DRM sample app you are about to create. (Otherwise, the sample app would become outdated with each new release of the Appstore SDK). To add the SDK JAR into the sample app:- Open Android Studio and select Open an existing Android Studio project.
- Browse to the SampleDRMApplication folder and select it. Then click Open.
-
Change to the Project view.

Project view
- Copy the amazon-appstore-sdk-[x].jar file.
- In the Android Studio project, expand app and select libs. Paste the amazon-appstore-sdk-[x].jar file into this directory.
-
Expand the app folder and open the build.gradle file. Customize the dependency on the amazon-appstore-sdk-[x].jar file you added. For example, if the Appstore SDK is version 3.0.3, your code would look as follows:
- Build the project by going to Build > Rebuild Project. It may take Android Studio a few minutes to build the project, as Gradle gets needed assets and builds the project. If Android Studio needs any specific files or libraries, you’ll be prompted to download them. After installing any needed assets, Android Studio will rebuild the project.
Step 3: Add the PEM file into your project’s assets
To add the PEM file to the sample app:- Sign in to the Developer Console with your developer account.
- If you already have an app, from the navigation bar, choose My Apps. Find your app, expand the row, and then select View to open the app listing. If you don’t already have an app, see Submit Your App to the Amazon Appstore.
-
In your app listing, navigate to the Additional information section to find the public key:
- On the Release Tracks screen, click View on the release.
- Alternatively, or if you don’t have a release created, click Policies and Compliance under App Setup in the sidebar.
-
Scroll to the Additional information section, then click View public key.
-
In the Public Key dialog box that appears, click the AppstoreAuthenticationKey.pem link to download the PEM file. This file contains your public key.

PEM file download link
- Copy the AppstoreAuthenticationKey.pem file and paste it into the app/src/main/assets folder of your Android Studio project.
Step 4: Connect to your Fire device through ADB
Connect your computer to either a Fire TV or Fire tablet through ADB. (The sample app runs on either Fire TV or Fire tablets.) See one of the following for details: In the sample app, note that the AndroidManifest.xml file (inside app > src > main), has the following feature defined:touchscreen property to false to support Fire TV. Without this, Fire TV devices won’t support your app.
Step 5: Install Amazon App Tester on your Fire device
When you’re developing your app with DRM or IAP (both of which need to communicate with the Appstore), you test your app using an APK called Amazon App Tester. The Amazon App Tester app simulates the Amazon Appstore client. To set up Amazon App Tester:- If you already have a previous version of Amazon App Tester installed, first uninstall it. (Note that this app is different from Web App Tester.)
- In your terminal or command prompt, browse to the directory where you downloaded the Amazon App Tester APK.
-
Install the APK on your Fire device using ADB:
The
-rparameter reinstalls the APK in case you already have App Tester installed. -
Open the Amazon App Tester app on your Fire device. To locate the installed app, see the following:
- Fire tablets: Click the Games & Apps menu and then click Library. Next to Amazon App Tester, click Open. (If you don’t see the app, check the Updates tab as well.)
- Fire TV: Go to Settings and click Applications. Click Manage Installed Applications. Click Amazon App Tester, and then select Launch application.
- Click the Appstore SDK API’s banner.
- Click DRM API Response Settings. If you don’t see this DRM API Response Settings option, you aren’t using the latest version of Amazon App Tester.
-
Select the license status you want for the app. If you leave it at the “Default,” the LICENSED status will be used.

DRM API Response Settings in App Tester
Step 6: Enter sandbox mode
Sandbox mode constrains calls that would normally go to the Appstore client to route to the Amazon App Tester app instead. Use this mode only for testing locally.-
In the same terminal where you connected to your Fire device through ADB, enter sandbox mode:
(Note that if you need to exit sandbox mode, run the following:
adb shell setprop debug.amazon.sandboxmode none.) Every time you reconnect to your Fire device through ADB, you need to reinitiate sandbox mode.
Step 7: Run your app
-
In Android Studio, click the Logcat tab and filter on
LicenseResponse. -
Click the Run App button
to run the app on your Fire device.
The sample app has a basic screen showing the license status and nothing more. A LICENSEDlicense status looks as follows:A
DRM sample app homescreen
NOT_LICENSEDresponse looks as follows:
License failure
-
You can also observe the messages logged to the console for the license status.

Logcat filtered on LicenseResponse
Understanding the sample app
The purpose of the sample app is to demonstrate how to integrate DRM. In the sample app, theonCreate() method in the MainActivity class (app/src/main/java/com/amazon/sample/drm/MainActivity.java) initiates the verifyLicense() method from the LicensingService class.
verifyLicense() method passes in two parameters: the application context (getApplicationContext()) and an implementation of LicenseVerificationCallback (new LicenseVerificationCallback(getApplicationContext())).
You can see the implementation of LicenseVerificationCallback in the LicenseVerificationCallback.java class:
LicenseVerificationCallback calls the onLicenseCommandResponse() method to get the license status:
onLicenseCommandResponse() method is called by the Appstore SDK after receiving the result of the verifyLicense() call from Amazon Appstore.
In this simple implementation, the app just logs the license status rather than triggering any kind of action:
LICENSEDNOT_LICENSEDEXPIREDERROR_VERIFICATIONERROR_INVALID_LICENSING_KEYSUNKNOWN_ERROR
LicenseResponse and observe what gets logged. The license responses will allow you to check that users are authorized to run the app.
For descriptions about each license status, see License statuses.
