Search code examples
androidplay-billing-library

Usage com.android.billingclient:billing and com.android.billingclient:billing-ktx library in Android Kotlin project


On going through the Lib version for billingclient in android help doc

Saw that they have billing and billing-ktx lib, Do we need both to be implemented in the app or when using kotlin project can we using billing-ktx lib alone?

I have implementing both the billing and billing-ktx in the project, seems to be working fine.


Solution

  • It depends on you project. If, for instance, you need to invoke queryPurchaseHistory from a suspend function then you need to use billing-ktx.

    In other words, if your project heavily relies on coroutines then billing-ktx will help you a lot. Also, when including billin-ktx, there is no need to include the standard billing library because it will be automatically added in the list of dependencies (you can double check it by yourself in Android Studio: from Project panel, expand External Libraries).

    If that's not the case, then the standard billing library is ok.