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

后端 未结 5 947
悲&欢浪女
悲&欢浪女 2020-12-02 15:33

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

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

5条回答
  •  醉话见心
    2020-12-02 16:38

    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:

    
    

    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

提交回复
热议问题