简体   繁体   中英

“This version of the application is not configured for billing” error when run from Android Studio

I have an application that's out in the store right now and I'm trying to implement in-app billing. I've read that it takes quite some time for the Google servers to update the visible apk on the alpha channel, so I waited for about a day, however I'm still getting this "This version of the application is not configured for billing through Google Play" error when I try to purchase an item after I click Run or Debug from Android Studio. So I tried uninstalling the app from the phone and downloading the alpha build from the Play Store. This time, I didn't get the error message but I don't think this is the way things should work. I simply can't upload a new apk when I make even a minor change. Does anyone know what's going on here? I'm also signing the debug builds with the same keystore I'm signing the release build with. And I also made sure both the apk on the alpha channel and the one I'm trying to debug have the same versionCode in build.gradle.

Turns out the problem was with the signing of the debug apk. For aynone that might see this question in the future, you need to sign every apk you build and run on your device with the same key you signed the alpha apk with. To do that you simply need to tell gradle which key you wish to use when building debug apk's.

My build.gradle looks something like this now:

android {
    signingConfigs {
        config {
            keyAlias 'my_key_alias'
            keyPassword 'somePassword'
            storeFile file('C:/Some/fake/directory/my_keystore.jks')
            storePassword 'someOtherPassword'
        }
    }

    ...

    debug {
        signingConfig signingConfigs.config
    }
}

My problem was that previously I was targeting the default keystore which was located in the Android installation directory, named debug.keystore, instead of the one I created myself.

More info on build configurations about app signing can be found here: https://developer.android.com/studio/publish/app-signing.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM