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

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 /AmazonInAppPurchasing/examples.

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 app directory for your project, create a new directory and name it "libs".

Copy the IAP 2.0 JAR file to your new libs directory.

If you are using a Mac, right-click the libs file, and select Reveal in Finder from the context menu. You will then be able to copy the IAP 2.0 JAR file from AmazonInAppPurchasing to your new libs directory. 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.gradle file and add the following code to the dependencies section of this file, then click the Sync Now link at the top of your build.gradle file to sync your changes:

dependencies {

...

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.