question

newuser-909d137a-d957-49b8-a31e-435c2848bb97 avatar image
newuser-909d137a-d957-49b8-a31e-435c2848bb97 asked ·

onProductDataResponse and other IAP 2.0 callbacks are not called, even without R8 obufscator

Android Studio: 4.0.1

Android Gradle Plugin: 'com.android.tools.build:gradle:4.0.1


compileSdkVersion = 29
targetSdkVersion = 29

gradle.properties

android.enableBuildCache=true
org.gradle.daemon=true
org.gradle.parallel=true
disableAllBuildTypesApartFrom=debug
org.gradle.jvmargs=-Xmx3092M -Dkotlin.daemon.jvm.options\="-Xmx1024M" -XX\:MaxPermSize\=3092m -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8
android.useAndroidX=true
pk12FileLocation=overridden
releaseTrack=alpha
increaseMinSdkForDev=false

org.gradle.configureondemand=false
android.enableJetifier=true
disableSomeBuildTypes=false
dexMemoryAllocation="1092m"
FLIPPER_VERSION=0.37.0

android.enableR8=true
android.enableR8.fullMode=true


Amazon IAP SDK: in-app-purchasing-2.0.76.jar

ProGuard R8 rules:

proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'


The application works with app tester. We exported the IAP subscription items JSON and used that with app tester. So our IAP SKUs match to what the app expects.

The 3 IAP callbacks that we use are

onProductDataResponse
onPurchaseUpdatesResponse
onPurchaseResponse
 
               
The callbacks are registered in onCreate of the Fragment.

public class BasePurchaseFragment2 extends Fragment {
                
.... 

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Context appCtx= MyApp.getApplicationComponent().application().getBaseContext();
    rxIapManager = new LCPurchController(this,appCtx); //underneath, this registers Amazon IAP SDK listeners
    Timber.d(TAG+ "::onCreate IS_SANDBOX_MODE:" + PurchasingService.IS_SANDBOX_MODE);
    disposable = new CompositeDisposable();
    setupBillingSubscriptionsOnce();
}

...}



When we go live testing on Amazon Fire8 HD device (this is the only one we have) . Updated to latest Fire OS 7 + patches. None of the callbacks are called. So our IAP flow does not work.

We put Toast messages to track what's being called in Live test, and none of them are firing -- so we know that Amazon APP store is not propagating events to call our application callbacks.



We tried with R8 obfuscation ( release { minifyEnabled true} ) and without R8 obfuscation ( release {minifyEnabled false} )


It did not make any difference (without minification the size of the APK is larger by 1mb or so... but that's the only obvious difference).


What can we do to resolve this?

iapandroid
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

newuser-909d137a-d957-49b8-a31e-435c2848bb97 avatar image
newuser-909d137a-d957-49b8-a31e-435c2848bb97 answered ·

Unfortunately we are not getting any help.


From Amazon developer support, we are now receiving 3rd time in a row this response, on the issue above:


"We are unable to proactively approve applications prior to submission to our store. Please evaluate our content guidelines and ensure all policies are complied with: https://developer.amazon.com/docs/policy-center/understanding-content-policy.html

"

I have no idea how above response is related to our technical question. Our app is in live testing and the Subscription integration with Amazon IAP SDK is not working.

So we are not publishing anything.

The same identical APK works with Apptester and does not work in live testing, and we are not sure what's going on.


Is anybody out there using Amazon IAP 2.0 SDK to get product listing for subscriptions, successfully ?







10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Levon@Amazon avatar image
Levon@Amazon answered ·

Hi there,

The following conditions must be met for IAP to work:

- You need to complete the Tax Interviews in your Developer Portal account

- All of your IAP items have to be published (their status must be shown as: Live)

- When building your project, please use the recommended ProGuard rules for IAP: https://developer.amazon.com/docs/in-app-purchasing/iap-obfuscate-the-code.html#proguard

10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

newuser-909d137a-d957-49b8-a31e-435c2848bb97 avatar image
newuser-909d137a-d957-49b8-a31e-435c2848bb97 answered ·

Hello Levon. Thank you for the follow up.

Unfortunately the above reply does not seem to help us.

Because all of those steps were completed prior to us submitting the issue.


> - You need to complete the Tax Interviews in your Developer Portal account

This has been done in early July. "Royalty Tax Identity Interview" and "Service Tax identity interview" are shown in Developer portal as completed, green mark.


> - All of your IAP items have to be published (their status must be shown as: Live)

That has been done, we have 1 subscription item, and it has been live since July 12.


> - When building your project, please use the recommended ProGuard rules for IAP:

That has been done as well. Your web page says:

" Note: R8 is now compatible with IAP, so you no longer need to disable R8 and exclude IAP from code obfuscation. IAP is compatible with Android Gradle plugin version 3.6.0 or higher."

We are using R8, and we also tried completely disabling obfuscation as well (which is the latest release we made into app testing)


The same exact .APK that tests well with the Tester App, then fails in live testing.

Today is august 26, 2020 -- we are in the same place.


I am worried that Amazon's IAP Android Java SDK ( version 2.0.76 Released September 1st, 2016 https://www.developer.amazon.com/docs/in-app-purchasing/iap-whats-new.html#iap-v2076 )

is no longer compatible with up to date Android development tools.

Otherwise, it is hard to come up with any other explanation.

This is why if would be good to know if anybody is using that SDK with android gradle 4.x plugin, and Amazon SDK IAP 2x Subscription purchases APIs.


We do not know how to move forward, so any help would be greatly appreciated.


--

May be this is not relevant to our issue, but important to note, that many of open source libraries that used to ask their consumers to update pro-guard rules for Proguard, are no longer doing that.

And with R8 they are able to incorporate their R8 rules, right into their library releases.

Amazon Java SDK development team, seems to have chosen not to update the SDK to include proguard/R8 rules automatically. Like for example, retrofit library

https://github.com/square/retrofit

"..

R8 / ProGuard

If you are using R8 the shrinking and obfuscation rules are included automatically.

.."

(they are configured in META-INF, see https://github.com/square/retrofit/tree/master/retrofit/src/main/resources/META-INF/proguard )

This is of course, much more convinient for developers consuming these libraries, as they no longer need to worry about this at all.

If anything, it would be great if Amazon IAP java SDK developers look into this to reduce complexity of integration.


10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

newuser-909d137a-d957-49b8-a31e-435c2848bb97 avatar image
newuser-909d137a-d957-49b8-a31e-435c2848bb97 answered ·

We have the subscription finally working.

The overall effort ended up to be almost 5 months. Even though the code to integrate with IAP, for us was, less than 2 weeks.

We could not get our subscriptions work in live testing, even though it worked with Tester app simulation.


The big problem was that Tester App does not provide the same response data in callback, compared to live testing , at least for subscriptions.

Which is why our app worked in our testing env, but not in live testing.

Additionally, in live testing, the subscriptions are extremely extremely difficult to troubleshoot. We had to add a whole layer of UIs so that we could see what the app was receiving from amazon app store.

This month (Nov 2020), amazon added a feature to the live testing, where subscriptions could be reset. So that we could test with same test account.

Otherwise, after one run, our test account could no longer be used, and we have to go and create whole new account, new email, credit card info, etc... after every test run.

So this addition of functionality for live testing flow, was a huge relieve.

---


Anyways, for benefit of others who might deal with IAP subscriptions:

public void onPurchaseResponse(final PurchaseResponse response)

when using Tester App, will return the SKU of the child subscription (the one with price, and term length)

When in live or production, amazon app store does not tell us what price + term the subscriber selected when purchasing, and instead, it returns us parent SKU (that does not have price or term).


Our app's logic was filtering out onPurchaseResponse results if the sku had no price or term (the parent sku). NotifyFulfillment was never called.


Which is why it was working in live testing, but did not work in prod.


It is very strange that Amazon had chosen not to tell the app with the onPurchaseResponse, what SKU the user actually purchased.


There are two workarounds for this that we saw (may be there are other alternatives, or may be our understanding is not up to date)


option 1) create parent+child SKU pair for every subscription term you have. This seems a bit backward, that is why then have parent-child sku model if there can only be one child.

option 2) after receiving onPurchaseResponse callback, use the receipt id, call a separate Amazon api via a REST call using that recept ID to receive a response that would tell you what subscription term the user had purchased.

https://appstore-sdk.amazon.com/version/1.0/verifyReceiptId/developer/2:SPOkNr03vVx0_u04edvPTf5t6VC-HHS4535VkVviYJp7fCvSepKM5Ys-_ODYdtw8:Y-tOqaWFAXCHluaxssj9VQ==/user/7m7UQpSnce0DcAOgcCZFVW5-sNc2rVYE6aQCGc6URNU=/receiptId/JyGJ5iEtYgFu1ngnQovTqSIHQxR53GsMLqkR1tKLp5c=:3:11

See

https://developer.amazon.com/docs/in-app-purchasing/iap-rvs-examples.html


This is of course, requires implementation effort and complicates the whole experience with yet another asynch call and the corresponding delay right before the fulfillment step.

--


We did not login a bug report in regards to this, what we think, a significant difference between App Tester and the actual live testing call backs.

Perhaps, if others think we should, we could log that in via feedback form.


@Levon@Amazon

10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.