How to make Amazon In-App Purchasing (IAP) 2.0 work with Android R8

amazon in-app purchase not working
amazon in-app purchase not allowed
amazon in-app purchase android
amazon in-app purchase tutorial
amazon in-app purchase history
amazon in-app purchase sample code
amazon in-app purchase refund
amazon app tester

It took a while after significant revenue loss to find out that Android R8 code shrinker prevents Amazon In-App Purchasing (IAP) 2.0 from working. Android Studio uses R8 by default now. Fortunately, the following in gradle.properties seems to be able to stop R8:

android.enableR8=false

I fear R8 will be mandated in the future, and it will be a disaster. I am trying to find a way to make them compatible. Someone posted a similar question on Amazon's forum that is supposed to be the best place for such questions, but I have a feeling that Amazon has stopped supporting the forum because my recent two questions there have received no response from Amazon.

I have the following in proguard-project.txt that is used by R8

#amazon
-dontwarn com.amazon.**
-keep class com.amazon.** {*;}
-keepattributes *Annotation*
-optimizations !code/allocation/variable
-optimizationpasses 1

As my understanding, R8 ignores optimizationpasses. I suspect that is the cause.

Edit(2019-05-30) The aforementioned script for proguard-project.txt is from Amazon's document for In-App Purchasing The app's build.gradle has the following:

release {
    minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
    signingConfig signingConfigs.Release

}

proguard-android.txt uses -dontoptimize, so it shouldn't be optimizing at all with ProGuard or R8, regardless of the number of -optimizationpasses specified. If you are interested, you can see the available default ProGuard files under build/intermediates/proguard-files/. proguard-android-optimize.txt is the one that would allow optimization.

At this point, given that R8's optimization doesn't seem to be on, I'm not sure if there's much of a workaround. I'd recommend that you file an issue with Google's Issue Tracker, giving as much detail as you can to help them reproduce the issue. They are generally pretty responsive to issues like this.

Obfuscate The App Code, When you obfuscate your code, you need to ensure that In-App Purchasing API Make sure that your obfuscation program does not obfuscate any class under In Gradle 3.4.0 and higher, Android Studio applies optimization through the R8 compiler. IAP is compatible with Android Gradle plugin version 3.6.0 or higher. The com.amazon.device.iap package provides classes and an interface that you use to implement In-App Purchasing in your Android app. This package contains the following interface and classes: ResponseReceiver : Class that receives broadcast intents from the Amazon Appstore.


Should work now with R8, add this to your main build.gradle dependencies:

buildscript {
    repositories {
        maven {
            url 'http://storage.googleapis.com/r8-releases/raw'
        }
    }
    dependencies {
        classpath 'com.android.tools:r8:1.6.42'  //Must be before the Gradle Plugin for Android. - Or any other version
        classpath 'com.android.tools.build:gradle:...'
     }
}

In-App billing not working since Android Studio defaulted to R8 tool , Home � Mobile APIs and Services � In-App Purchasing (IAP) 2.0 We get a FAILED response in onPurchaseResponse. By disabling R8, in-app purchases again work. IAP was working locally. that IAP works with R8 (https:// developer.amazon.com/docs/in-app-purchasing/iap-obfuscate-the-code.html). You configure your app with the SKU information for these items. The component sends the necessary information to the In-App Purchasing API. The Amazon In-App Purchasing Component uses a wrapper over the IAP API. Only a limited feature set from IAP is available; as such, the documentation here is a modified subset of the IAP documentation.


build.gradle

release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }

proguard-rules.pro

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

gradle.properties

# Disables R8 for Android Library modules only.
android.enableR8.libraries = false
# Disables R8 for all modules.
android.enableR8 = false

This works for me.

In-App Purchasing Overview, If you are using Android Studio as your to work with the IAP sample apps: Import the IAP sample apps to your Copy the IAP 2.0 JAR file to your new libs directory. Yes, to make the app available on the Amazon Appstore, you must use the Amazon In-App Purchasing API for all eligible purchases. Q6: Which eligible items must use the In-App Purchasing API? For selling any digital goods and services, your app must use the Amazon In-App Purchasing API. In-App Purchases can be in the form of the following:


Get Started with IAP, onProductDataResponse and other IAP 2.0 callbacks are not called, even without R8 obufscator. 0 Likes Android IAP in Fragment. 0 Likes Reset Tester Entitlements not working. 2 Likes I'm using In-App Purchasing Subscription, how can i get subscription status inside app after subscription. If user is� It took a while after significant revenue loss to find out that Android R8 code shrinker prevents Amazon In-App Purchasing (IAP) 2.0 from working. Android Studio uses R8 by default now.


All Posts in In-App Purchasing (IAP) 2.0 - Forums, onProductDataResponse and other IAP 2.0 callbacks are not called, even without R8 obufscator. 0 Likes avatar image. aditya mohatta asked � 8 days ago � Mobile APIs and Services In-App Purchasing (IAP) 2.0 Android IAP in Fragment. 0 Likes App Keeps getting rejected Because it says we have IAP. 0 Likes. Whether you are completely new to In-App Purchasing, or have existing items for sale on other Appstores like Google Play, this video will help point you in the right direction. Category Science


iap, If you are ready to submit your app to the Amazon Appstore, consider Android Studio applies R8 optimization by deblunder in Gradle 3.4.0 or higher. Make sure that your obfuscation program does not obfuscate any class under the com. amazon. Note that the IAP API is compatible with ProGuard versions v4.7 or later. Migrating From Google Play In-App Billing (IAB) v3.0 to Amazon In-App Purchasing (IAP) v2.0 Now, let's discuss the differences between Google Play’s In-App Billing (IAB) and Amazon’s In-app Purchasing (IAP) and give a high-level description of how to adapt your app to use both API sets.