Amazon Appstore Easy Port Billing Aspects
If your app uses Google Play Billing and is integrated with the Play Billing Library version 5.2.1, you can use the Amazon Appstore Easy Port billing aspects in your app to port it to Fire OS. The Easy Port billing aspects target Play Billing Library v5.2.1 and replace the library's API calls with calls from Appstore Billing Compatibility v4.1.0.
Requirements
- App must not be already integrated with Amazon In-App Purchasing (IAP) APIs. App must not use Amazon IAP through the Appstore SDK or the Appstore Billing Compatibility SDK.
- App must be integrated with the Amazon Appstore Easy Port plugin. For integration steps, see Integrate Amazon Appstore Easy Port plugin.
- App's target API level must be 24 or higher, or app must have Java8+ API's desugaring enabled.
- In an activity in the main UI thread, app must instantiate the Google
BillingClient
object in theonCreate()
method. App must have only one instance ofBillingClient
present at a time. - All business logic related to in-app billing must be in a single module, where the aspects are applied. The aspects can't be applied to multiple modules.
Add aspects and related resources
Use the following steps to add the Amazon Appstore Easy Port billing aspects and related resources to your project.
- Identify the module that directly integrates with Play Billing Library v5.2.1 and apply the Easy Port plugin to the module. For instructions, see Apply and configure Amazon Appstore Easy Port plugin.
- After configuring the plugin and syncing the changes, you can find a task named
AspectDownloadTask
in your gradle tasks under theeasy Port
group. Running this task downloads the required aspects and copies the assets to the appropriate folder as follows:- src/easyPort - folder that contains aspect classes
- src/main/java/easyport - folder that contains Easy Port annotations
libs/appstore-billing-compatibility-<version>.jar - the Appstore Billing Compatibility SDK JAR file
To find the path to the Appstore Billing Compatibility SDK JAR file, check the
AspectDownloadTask
logs.
Example logs:Add the following libs to the dependencies block in build.gradle. [libs/appstore-billing-compatibility-4.1.0.jar]
Note: If you aren't using the standard Android folder structure (src/main/java) in your module, you must manually add the aspects with the following instructions.Alternative method to add the aspectsYou can manually download and add the aspects and resources by using the following steps.
- Download the billing aspect files here.
- In the module's src folder, add the easyPort folder that contains the aspect files.
- Download the billing annotation files here.
- In the module's main java folder, add the easyport folder that contains the annotations.
- Download the Appstore Billing Compatibility SDK, and copy the JAR library file to the module's libs folder. If obfuscating your code, follow the guidance in IAP and code obfuscation to make sure IAP functionality isn't affected by code obfuscation.
- Add the downloaded JAR file from the previous step to the dependencies block in your module's build file as follows.
easyPortImplementation(files("libs/appstore-billing-compatibility-<version>.jar"))
easyPortImplementation(files("libs/appstore-billing-compatibility-<version>.jar"))
<version>
is the version of the downloaded Appstore Billing Compatibility SDK JAR file. - In the easyPort folder that contains the aspects from the step 2, create an assets folder and add the AppstoreAuthenticationKey.pem file. To obtain the PEM file, follow the steps in Configure Appstore SDK with your public key.
- If your app has subscriptions, follow these steps.
- Add your subscription items in the Developer Console and export them into a JSON file. For instructions, see Appstore Billing Compatibility Subscriptions.
- After you export the in-app item list, save the amazon.sdktester.json file in the assets folder under the easyPort folder.
- Resolve any conflicts.
Important: Amazon Appstore Easy Port finds, transforms, and replaces Google Play Billing API calls with Amazon IAP API calls. To successfully build, your project's Easy Port flavor must include the Google Play Billing Library and integration code. You can add this dependency in the default configuration, or the configuration specific to Easy Port.
Related topics
Last updated: May 23, 2024