Developer Console

Appstore Billing Compatibility SDK

If you have an existing Android app that is integrated with the Google Play Billing Library, you can use the Appstore Billing Compatibility SDK to port your app to the Amazon Appstore with minimal changes. The SDK supports consumable, entitlement, and subscription in-app purchases (IAP). The Appstore Billing Compatibility SDK is compatible with the Google Play Billing Library version 4.0 and 5.0.

The following table shows a feature comparison between the Google Play Billing Library, the Appstore SDK, and the Appstore Billing Compatibility SDK.

Feature comparison
Feature Google Play Billing Library Appstore SDK Appstore Billing Compatibility SDK
Subscriptions
Entitlements
Consumables
Digital Rights Management (DRM)

Download the Appstore Billing Compatibility SDK

Download the Appstore Billing Compatibility SDK here:

The download includes the Appstore Billing Compatibility JAR file and API documentation.

Integrate the Appstore Billing Compatibility SDK

Use this step-by-step guide to integrate the Appstore Billing Compatibility SDK with your app.

Step 1. Add the SDK to your app

Manually add the Appstore Billing Compatibility SDK to your Android app project:

  1. Expand your app folder and select libs (If you don't have a libs folder, create one). Paste the appstore-billing-compatibility-4.1.0.jar file into this directory.
  2. Open your app folder's build.gradle file and add a dependency on the appstore-billing-compatibility-4.1.0.jar. For example:
     dependencies {
         implementation files('libs/appstore-billing-compatibility-4.1.0.jar')
     }
    
  3. Sync your project by selecting Sync Now at the top of your build.gradle file in your IDE.

Optionally, you can remove the Google Play Billing Library dependency from your app.

Step 2. Configure your Android app with the 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 Amazon 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 Android app with the public key:

  1. Log in to the Developer Console with your developer account.
  2. Go to Apps & Services > My Apps. If you have an existing app, click on the app. Otherwise, create a new app by clicking on the Add New App button and selecting Android, then complete the New App Submission page.
  3. Go to the Additional information section on the Upload Your App File screen.
  4. Click View public key.
  5. In the Public Key dialog box that appears, click the AppstoreAuthenticationKey.pem link to download a PEM file. This file contains your public key.
  6. Copy the AppstoreAuthenticationKey.pem file. Then paste it into the app/src/main/assets folder of your Android app project. If you don't have this folder, create one.

Optionally, you can remove the Google Play Billing public key dependency.

Step 3. Configure your AndroidManifest.xml file with receiver

The Appstore Billing Compatibility SDK performs all of its activities in an asynchronous manner. Your app needs to receive broadcast intents from the Amazon Appstore through the BillingResponseReceiver class. This class is never used directly in your app, but for your app to receive intents, you must add an entry for the BillingResponseReceiver to your manifest.

The following example code shows how to add a BillingResponseReceiver to the AndroidManifest.xml file for the Appstore Billing Compatibility SDK. If your app targets Android 12 or higher, you must explicitly set android:exported to true in the MainActivity and ResponseReceiver.

<application>
...
    <activity android:name="com.amazon.sample.iap.entitlement.MainActivity"
              android:label="@string/app_name" android:exported="true" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    
    <receiver android:name="com.amazon.device.iap.billingclient.api.BillingResponseReceiver" android:exported="true"
              android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY">
        <intent-filter>
            <action android:name="com.amazon.inapp.purchasing.NOTIFY" />
        </intent-filter>
    </receiver>
...
</application>

Step 4. Update import statements

Update Google Play Billing imports in your app's codebase to use Appstore Billing Compatibility SDK imports by finding all usages of the com.android.billingclient.api prefix and replacing them with the com.amazon.device.iap.billingclient.api prefix.

If any Appstore Billing Compatibility SDK import statement is unresolved, that indicates it isn't supported by the Appstore Billing Compatibility SDK. Remove or modify its usage in the app to make it work with the Amazon Appstore.

Next steps

See Implement the Google Play Billing Interface.


Last updated: Oct 27, 2023