Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to debug locally Google Play's in-app billing in Android Studio?

I am getting this error testing in-app subscription products locally.

authentication is required. you need to sign in to your google account

I was able to check the the inventory for the product but shouldn't I also be able to purchase it?

There are a number of posts about why this error might occur which I thought were addressed:

  • the product is released in the beta channel with in-app billing enabled
  • i am logged into Play Store with a test user licensed account on the device.

Is the only way to test actual purchases via the beta/alpha channels - not straight from android studio. This post suggests it possible (see screen shot)

http://developer.android.com/google/play/billing/billing_testing.html#billing-testing-test

like image 973
jenson-button-event Avatar asked Mar 20 '16 11:03

jenson-button-event


People also ask

How do I check my Google Play Billing Library?

To test your Google Play Billing Library integration using test tracks, do the following: Publish your app to a test track. Note that after you publish an app to a testing track, it can take a few hours for the app to be available for testers. Ensure each tester opts-in to your app's test.

How do I check my Google Play in-app purchases?

On selecting the device, the uploaded/selected app will automatically open in the device in question. Alternatively, you can sign in to Google Play Store, download and install a published app and test its in-app purchase feature. Just pick the Install via Google Play Store option.


2 Answers

EDIT: This is now superseded by the newly accepted answer.

In essence, in-app billing payments can only be tested with a release-signed apk (the one we upload to Google Play Console).

Here are some steps that got me attached to a signed apk with Android Studio:

I'm on Windows. It helps having adb.exe in the PATH, for me that's:

C:\Users{your-username}\AppData\Local\Android\sdk\platform-tools

  1. In Google Play Console, ensure the app is published (< is a one-time manual step after its initially processed) in alpha or beta channel and you have a licensed test gmail account (from the Account Settings section) that is also in the list of alpha/beta testers and is not the owner of the app account. This account is the only account on the device. Release the apk and ensure it all works from an installed version from the Play Store.
  2. Have these settings: In AndroidManifest.xml under application node
android:debuggable="true" tools:ignore="HardcodedDebugMode" 

Note: Propably, you need to add: xmlns:tools="http://schemas.android.com/tools" property to your manifest tag. It may look like:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"  package="your.package"  xmlns:tools="http://schemas.android.com/tools"> 

And in your build.gradle file under android > buildTypes > release, add:

debuggable true

  1. Generate a signed APK from Android Studio

  2. Attach your device for USB debugging. Remove current install:

adb uninstall {yourdomain}.{yourpackagename}

  1. Install it (from the release path)

adb install app-release.apk

  1. Open the app on the device. From Android Studio's Run menu, last option is "Attach debugger to Android Process" - select your device. You are now debugging.

NB for in-app billing the build number needs to match the one currently published on Play Store

like image 133
jenson-button-event Avatar answered Sep 30 '22 17:09

jenson-button-event


The following worked for me launching from my IDE (Android Studio)

1) Go to your https://play.google.com/apps/publish/ Under 'Developer' Account/Settings/Account details/License Testing

2) Add the 'Default Google Play' email address that corresponds with the device you are testing

Source: https://engineering.memrise.com/faster-in-app-billing-subscriptions-testing-8e68551b4e2f

like image 41
Mitch Thornton Avatar answered Sep 30 '22 17:09

Mitch Thornton