Skip to content

Setup for Android Google Play

Jean-Christophe Hoelt edited this page May 28, 2019 · 3 revisions

Setup Android Applications

Create Android Applications

Recently you can test IAP on PlayStore only if your app is already published. If you don't want to make it available before testing, you can publish it in alpha (recommended) or beta state instead of production.

  • Create a release APK of your app and sign it.
  • Create a new application in the Developer Console.
  • Upload your APK.
  • Enter the app description, logo, etc. then click on save.

Add Android Billing Key

Your license key for in-app billing should be added manually to your project. This key is found in Services and API in the Google Play Developer Console.

The license key is set during installation:

cordova plugin add cc.fovea.cordova.purchase --variable BILLING_KEY="MIIB...AQAB"

Replace MIIB...AQAB with your own android license key.

To change it, remove the plugin and add it back with the new key.

Create New Products on Android

  • Add in-app purchases items from the Developer Console
  • Activate them
    • No need to publish the app.

Purchase types:

  • for consumable, non consumable and non-renewing subscriptions choose "managed".
  • for free and paid subscriptions, choose "subscriptions".

Test Android Applications

The Google Account on the test device should not be the same as the developer account.

You can test purchase with no charge by adding google test account in your developer console -> 'Settings -> gmail accounts with testing access".

It's easier to be done with an alpha published app. You add users to a google group then send a link and they sign up on their own.

To test locally, install the same same release signed app on a device which is logged into play store using a test account. If you use the debug build, you can do some actions, however you will not be able to buy the product.

Sometimes, publishing the app (for a short period) on Google Play proved to be the only way to make testing IAP work.

Debug an Android Release Build

  • Upload the build to Alpha/Beta channel of google play
  • Open the cordova project in Android Studio
  • Add the following to your application node in the android manifest : android:debuggable="true"
  • Build a new APK using Android Studio
  • Deploy to your usb device using ADB install command adb -d install /path/to/release.apk
  • It loaded the release app on the physical device and you are still able to inspect the app via chrome.