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
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 the corresponds with the device you are testing
Source: https://engineering.memrise.com/faster-in-app-billing-subscriptions-testing-8e68551b4e2f
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:AndroidManifest.xml
underapplication
nodeAnd in your
build.gradle
file underandroid > buildTypes > release
, add:Generate a signed APK from Android Studio
Attach your device for USB debugging. Remove current install:
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
I assume, that when you initialize the 'billing helper', you provide it with a Base64 public key from the developer console. That key corresponds to your release certificate.
The message you get suggests, that you are probably trying to run your app in debug mode. That means, that your app is signed using the debug certificate (a default one). If I am right, that explains, why you are not being authenticated.
Unfortunately, the only way to test the in-app billing, is within an app signed using the release certificate, on a device logged in to an account, that is defined as 'Gmail accounts with testing access' and your app has to be published to Google Play (alpha/beta/production).
Perhaps another approach:
Similar in most ways to what is mentioned here except you just point to your release keystore within your debug buildType.
Exact steps: 1) In your app Gradle file in the
android
tag add a release signing config:and add the signing config to your debug buildType:
2) Make sure the
versionCode
andversionName
in your app gradle >defaultConfig
section matches exactly what's in the apk you uploaded to the play store:3) Make sure to add the billing permission to your manifest:
<uses-permission android:name="com.android.vending.BILLING" />
4) Don't forget to add your IAB (In App Billing) products per the docs
5) Set your break points and debug per usual.
6) After you have successfully tricked out your code, don't forget to clean up at least the changes in your gradle file such as removing the signing config so your kestore passwords aren't floating around in space.
With any luck you will be able to do local debugging for your IAB code.
Cheers.