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

后端 未结 5 935
悲&欢浪女
悲&欢浪女 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:19

    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:

    signingConfigs {
            release {
                storeFile file("Path_to_your_Production_release_Keystore.jks")
                storePassword 'your_keystore_password'
                keyAlias 'your_key_alias'
                keyPassword 'your_key_password'
            }
        }
    

    and add the signing config to your debug buildType:

    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt', 'proguard-google-api-client.txt'
        }
        debug {
            signingConfig signingConfigs.release
            debuggable true
        }
    }
    

    2) Make sure the versionCode and versionName in your app gradle > defaultConfig section matches exactly what's in the apk you uploaded to the play store:

    defaultConfig {
        applicationId "com.groovypackagename.groovyapp"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 56
        versionName "0.9.6"
        multiDexEnabled true
        resConfigs "en"
    }
    

    3) Make sure to add the billing permission to your manifest:

    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.

提交回复
热议问题