‹ Amazon Doc Home

Amazon Appstore Integration Guide

For the Javascript version of cocos2d-x v3.x - (all other versions)

Prerequisites

NOTE:

If you are using Amazon plugin then you must install IAP plugin at first to make it to work.

SDK Version

Integration

Open a terminal and use the following command to install the SDKBOX Amazon plugin. Make sure you setup the SDKBOX installer correctly.

$ sdkbox import amazon
$ sdkbox set store amazon

Extra steps

The following step assumes you have already registered as a Amazon Developer in the Amazon Developer Portal and created a new game there.

Setup Android

<meta-data android:name="store" android:value="amazon" />

NOTE: If you submit your apk to other store, such as Google Play, please remove this line or set the store with googleplay, otherwise, you will get wrong configuration for the other store. Example: <meta-data android:name="store" android:value="googleplay" />

$ sdkbox set store googleplay

JSON Configuration

SDKBOX Installer will automatically inject a sample configuration to your sdkbox_config.json, that you have to modify it before you can use it for your own app

Here is an example adding Amazon:

{
    "ios":
    {
    },
    "android":
    {
    },
    "amazon" :
    {
        "iap":
        {
            "items":{
                "remove_ads":{
                    "id":"com.cocos2dx.non1",
                    "type":"non_consumable"
                },
                "double_coin":{
                    "id":"com.cocos2dx.non2",
                    "type":"non_consumable"
                },
                "coin_package":{
                    "id":"com.cocos2dx.plugintest2"
                },
                "coin_package2":{
                    "id":"com.cocos2dx.plugintest3"
                }
            }
        }
    }
}

How to test

more info https://developer.amazon.com/public/apis/earn/in-app-purchasing

Proguard (optional)

proguard.config=proguard.cfg
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

# cocos2d-x
-keep public class org.cocos2dx.** { *; }
-dontwarn org.cocos2dx.**
-keep public class com.chukong.** { *; }
-dontwarn com.chukong.**

# google play service
-keep public class com.google.android.gms.** { public *; }
-dontwarn com.google.android.gms.**

-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

#sdkbox
-keep public class com.sdkbox.** { *; }
-dontwarn com.sdkbox.**

#amazon
-dontwarn com.amazon.**
-keep class com.amazon.** {*;}
-keepattributes *Annotation*

https://developer.amazon.com/public/apis/earn/in-app-purchasing/docs/code-obfuscation

Note: Proguard only works with Release builds (i.e cocos run -m release) debug builds do not invoke Proguard rules.