License checking overview
The DRM API allows you to check whether the user is licensed for the content. The Appstore client looks for an appropriate content license in the app’s local cache. If the license is found in the local cache, it will be returned in the response. (Hence even if a user is offline, the app will still run.) If the license does not exist in the cache, the Appstore client will call the Appstore to retrieve the content license. You will need to use the DRM API to initiate the license checking and then apply logic to authorize or deny the user based on the status of the license returned by Amazon.DRM in Appstore SDK
Previously, when you uploaded Android APKs into the Amazon Appstore, you had the option to select Yes or No for “Apply Amazon DRM?”. If you selected Yes, Amazon would add DRM to your app. With the Appstore SDK, the Developer Console no longer displays this option. If you want to add DRM to your APK, use the DRM API (included in the Appstore SDK) to incorporate license checking in your app. If you haven’t upgraded to the Appstore SDK, but use an older IAP SDK (or aren’t using IAP), the option to “Allow Amazon to Apply DRM?” appears after uploading your APK.Warning messages
If you upload an APK that uses an older IAP SDK version or no SDK at all, then you see the following warning.
DRM sample app
A DRM sample app and tutorial is available showing the DRM API code in a simple integration.Implement DRM in your app
To implement DRM in your app, do the following:- Follow the instructions in Integrate the Appstore SDK to add the Appstore SDK into your Android project.
-
Update your app’s manifest file.
-
Add an entry for the
ResponseReceiverto your manifest. The following code example shows how to add aResponseReceiverto the AndroidManifest.xml file for DRM. If your app targets Android 12 or higher, you must explicitly setandroid:exportedtotruein theMainActivityandResponseReceiveras shown in the following example: -
If your app targets Android API level 30 or higher, you must define the list of packages your app needs to query in the AndroidManifest.xml file. To be able to query Amazon App Tester and Amazon Appstore, add the following code to your manifest file.
-
Add an entry for the
-
Initiate the license verification by calling
verifyLicense(). This method is exposed in theLicensingServiceclass. It takes two parameters as input:ApplicationContext- Your implementation of
LicensingListener
onCreate()method of yourMainActivityonCreate()of a custom implementation of theApplicationclass
-
Implement
LicensingListener.LicensingListenerdefines a single method:onLicenseCommandResponse(final LicenseResponse licenseResponse). This method is called by the Appstore SDK after it receives the result of theverifyLicense()call from Amazon Appstore.LicenseResponsewill contain the status ofverifyLicense()call. The response will contain one of the following statuses:LICENSEDNOT_LICENSEDERROR_VERIFICATIONERROR_INVALID_LICENSING_KEYSEXPIREDUNKNOWN_ERROR
LicensingListenerinterface is as follows. (This code merely logs the returned status of the license.)
License statuses
When you callverifyLicense(), the licensing service sends back one of the license statuses defined in the following table.
| License Status | Description |
|---|---|
LICENSED | The user has a valid license. |
NOT_LICENSED | The user does not have a valid license. He or she is not entitled to use the application. |
ERROR_VERIFICATION | There was an error in trying to verify the license. Reasons for the verification error might be due to the following:
|
ERROR_INVALID_LICENSING_KEYS | The user has license keys but they are not valid. Reasons for the invalid licensing keys might be due to the following:
|
EXPIRED | The user’s license has expired and the user’s current license is now not valid. A license is valid for 60 days. After 30 days, the Appstore tries to renew the license every 24 hours.If the user is offline for more than 60 days, the Appstore will be unable to renew the license before it expires. If the license expires, the app will no longer launch for the customer.Other reasons for expired licenses might be due to the following:
|
UNKNOWN_ERROR | This status indicates an internal error at Amazon’s end. |
DRM library obfuscation
Most of the Appstore SDK library is already obfuscated (before it was packaged into a JAR). However, some developer-facing classes are not obfuscated. The following DRM library classes are not obfuscated:LicensingListenerLicensingServiceLicenseResponseRequestId

