I'm trying to test in-app subscriptions for an app I'm working on. The problem is that the SkuDetails list comes empty. I've read in the documentation that the app must first be published to alpha before the subscription stuff can be tested. As I understand it, after the app is published to alpha I can test a build with the same version on the device and can debug and all that. I don't need to download the release build from alpha. One of the possible issues is that the app seems to need Google approval before being published to alpha (it has the status of Pending Publication). I don't understand the need for approval as it is just an alpha build.
For now I'm just trying to get the SkuDetails list. In GooglePlay Console I have setup a single subscription and set it to Active. Code wise I have this function:
fun setupBilling(context: Context, callback:
(result: BillingResult,skuDetailsList: List<SkuDetails>) -> Unit) {
billingClient = BillingClient.newBuilder(context)
.enablePendingPurchases()
.setListener(this).build()
billingClient.startConnection(object : BillingClientStateListener {
override fun onBillingSetupFinished(billingResult: BillingResult) {
if (billingResult.responseCode == BillingResponseCode.OK) {
querySkuDetails(billingClient, callback)
}
}
override fun onBillingServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
})
}
The querySkuDetails function looks like:
private fun querySkuDetails(client: BillingClient,
callback: (result: BillingResult,
skuDetailsList: List<SkuDetails>) -> Unit) {
val params = SkuDetailsParams.newBuilder()
params.setSkusList(skuList).setType(BillingClient.SkuType.SUBS)
client.querySkuDetailsAsync(params.build()) {
billingResult, skuDetailsList ->
callback(billingResult,skuDetailsList)
val msg = billingResult.debugMessage
Log.d(TAG, "List Size: ${skuDetailsList.size}")
Log.d(TAG, msg)
}
}
In the above code, skuList is a list of String with a single element that is my subscription identifier from the Play Console.
There is no debugMessage and the list size is always 0 even though it should be 1.
Any help is appreciated.
Thanks! Razvan
After 4 days since I uploaded the Alpha version on Google Play, Google approved it and now everything works. So the only thing that I had to do was to wait for Google to approve the app (even if it was just an alpha version).