Why is the Google Play Billing Library not shown u

2020-01-29 16:34发布

问题:

I'd like to make an android application with in app purchases, I read often that I have to download the Google Play Billing Library from SDK Manager

(e.g. http://www.techotopia.com/index.php/An_Android_Studio_Google_Play_In-app_Billing_Tutorial#Installing_the_Google_Play_Billing_Library ), but I can't find it there. Does I need this file? If yes, how can I manage that it is shown to me? On the developers.android webside is nothing written of the Google Play Billing Library, but if I copy their sample code to my project, I get many errors. I searched for Example projects for example on github, I found one, but when I run it, the app crashes. Is there any sample project, I think this would solve my problems?

THANKS !!!

回答1:

Checking the offical blog:

Play Billing Library is available through Maven repository

Just add:

dependencies {
    ...
    compile 'com.android.billingclient:billing:1.0'
}

You can find more details about the library in the official doc.



回答2:

You are referring to the old Google Play Billing library (v3), which if you really want to implement you can find it as part of the TrivialDrive demo app below. You can copy parts that you need (aidl, util) and change your app as per demo sample.
https://github.com/googlesamples/android-play-billing/tree/master/TrivialDrive

~~~

The new version of Play Billing library v1.0 is covered by Garbriele Mariotti's answer (above). If you happen to use a platform that doesn't support Maven, Gradle or AARs I will be making it available soon (UPDAT to follow) as an Eclipse based project that you may be able to import into your IDE the same way you wanted to import the old library downloaded through SDK Manager (which probably doesn't include it anymore as they dev team doens't want you to use it anymore).

If you just want to download it and look at it, you can download it from here:
https://google.bintray.com/play-billing/com/android/billingclient/billing/1.0/

~~~

Google Play Billing 1.0 library for Eclipse available from here:
https://github.com/dandar3/android-google-services-billing/tree/1.0



回答3:

Play Billing Library is available through Maven repository.

Add in top level build.gradle file

    buildscript {

    mavenCentral()     
    }

    ................
    allprojects {

    repositories {

    mavenCentral()
       }
    }

Add dependency into module level build.gradle file.

   implementation 'com.android.billingclient:billing:1.0'

Then After implement in app billing sample example into your project.

https://codelabs.developers.google.com/codelabs/play-billing-codelab/#0

This link you can find sample code of in app billing example of google

https://github.com/googlesamples/android-play-billing