Get Started with IAP
If you have never worked with the Amazon In-app Purchasing SDK, or have never implemented the IAP API before, this page will help you set up your IDE and familiarize you with the recommended development, testing, and submission workflow for IAP.
For the sake of simplicity, this topic will walk you through importing the IAP sample apps to your IDE, rather than starting a new project from scratch, since most developers prefer to start with a sample. To learn more about how to actually implement the IAP API itself, see Implementing IAP.
- Download the SDK
- Set Up Your Development Environment: Android Studio
- Set up App Tester
- Submit Your App and In-App Items
Download the SDK
If you have not already done so, download the Amazon Android SDKs to your computer:
Amazon Android SDK Download (On the SDK download page, click the Android link).
After you extract the files, the IAP SDK files are contained in the folder named AmazonInAppPurchasing.
Set Up Your Development Environment: Android Studio
If you are using Android Studio as your IDE, you can still import the sample projects, export them as APKs and run them on an Android device.
To set up your Android Studio development environment to work with the IAP sample apps:
- Extract the contents of the Amazon-Android-SDKs.zip file somewhere to your local machine.
- Start Android Studio.
Import the IAP sample apps to your workspace:
- On the Welcome to Android Studio screen, select Import Project (Eclipse ADT, Gradle, etc.) to open a project import window.
- On the Select Eclipse or Gradle Project to Import window, navigate to the location where you extracted the contents of the Amazon-Android-SDKs.zip file, then navigate to and select
- Select the directory of one of the three IAP sample projects, and click OK to go to the Import Project from ADT screen.
- On the Import Project from ADT screen, select a destination directory, and click Next.
- On the screen that follows, leave all of the default settings checked, and click Finish to import the IAP sample app project.
- Repeat these steps for each sample app.
- Add the IAP 2.0 JAR/library file:
- From the upper-left corner of Android Studio (just under the tab for your project), select Project from the drop-down menu (other choices are Android or Packages) to display a directory tree for your project.
- Under the
appdirectory for your project, create a new directory and name it "libs".
Copy the IAP 2.0 JAR file to your new
If you are using a Mac, right-click the
libsfile, and select Reveal in Finder from the context menu. You will then be able to copy the IAP 2.0 JAR file from
AmazonInAppPurchasingto your new
libsdirectory. When the directory refreshes, you will see the file in this directory in Android Studio.
Right-click the IAP 2.0 JAR file, and select Add as Library…
The IAP library will be added to the list of gradle dependencies for your project. You should be able to successfully build the sample app project now.
Note: If you would prefer to use gradle to add the library, open your
build.gradlefile and add the following code to the dependencies section of this file, then click the Sync Now link at the top of your
build.gradlefile to sync your changes:
compile fileTree(dir: 'libs', include: ['*.jar'])
- Repeat these steps for each sample app project.
- Generate the APK for one of the sample apps:
- Connect your Android mobile device to your development computer.
- In Android Studio, click Debug, and select your running device to install the app to that device.
Note: Adding the Javadocs to your project in Android Studio is not currently an option for the Amazon Android SDKs because Android Studio requires that the Javadocs be available as their own JAR file, which is not currently available as part of this SDK.
You should now be able to run this sample app on your mobile device.
Note that when submitting your actual app to the Amazon Appstore, an Amazon signature will be applied to your app, regardless of whether you submit a signed or unsigned APK.
Set up App Tester
Note: Before starting any actual testing, read about your IAP testing options and the recommended testing process. See Testing In-App Purchasing (IAP).
Amazon provides an App Tester tool for performing unit testing of IAP. You can test out this tool with the IAP sample apps.
To install the App Tester and enable the sample app to run on the App Tester:
- Follow the instructions in Installing and Configuring the App Tester.
From the sample app, using the
adb pushcommand, copy the amazon.sdktester.json file to the
/mnt/sdcard/amazon.sdktester.jsonpath on your device:
$ adb push <_Your_JSON_File_Folder_>/amazon.sdktester.json /mnt/sdcard/
- Follow the instructions in the App Tester User Guide to learn more about testing an app with App Tester. If you need help setting up the test cases to check with the App Tester, see Defining and Executing Test Cases for IAP.
Submit Your App and In-App Items
After you finish testing your app, you can submit your app and in-app items to Amazon.