Troubleshooting bug with in-app purchases on Android? Chrome remote debugger

I have a bug with in-app purchases on Android, but I don’t know to troubleshoot it. In order to do in-app purchases, you have to upload your APK to Google Play with the release key. When I run that version of the app, I can’t get any debugging messages using the Chrome remote debugger.

But if I run locally, I have the debug version that doesn’t have the release key, and thus can’t actually make in-app purchases.

Does anyone have any ideas?

Once you upload the app for the first time, you can then run and debug it locally and in app purchases will still work, you don’t need to upload it each time. (As long as it is the same version number and the apk is signed)

This is what I use to sign and test iap locally:
https://alexdisler.com/2016/04/01/tips-for-signing-installing-cordova-apps-on-android/
and
https://alexdisler.com/2016/04/04/testing-cordova-in-app-purchases-on-ios-android/

2 Likes

Perfect! I’m still learning Ionic so I didn’t know how to run APK’s locally.

FYI, I’m using your plugin. I evaluated cordova-plugin-purchase and and android-inapp-billing but I liked your API the best. It’s been really nice so far, getProducts and restorePurchases have been a piece of cake to work with so thanks for the hard work!

edit: I should also mention for other readers that the bug is with my code for server validation of receipts, not Alex’s plugin!

1 Like

Ok, there is one gotcha. Using the adb command you provided, I can’t see the variables in my log messages. Here is one example:

04-30 16:27:41.229 11221 11221 I chromium: [INFO:CONSOLE(25642)] "restore purchase data: ", source: file:///android_asset/www/lib/ionic/js/ionic.bundle.js (25642)

The code that produced the message:

  .then(function(data) {
    $log.debug("restore purchase data: ", data);

Edit: as a workaround I’m doing a JSON.stringify() on my objects and then using string concatenation.