Android Play Billing Library: onSkuDetailsResponse responseCode is 0, but the size of skuDetailsList is also 0
Asked Answered
H

10

22

I'm now using the new Play Billing Library

Basically, I followed the documentation to query available items to purchase

 SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
            params.setSkusList(skuList).setType(itemType);
            mBillingClient.querySkuDetailsAsync(params.build(),
                    new SkuDetailsResponseListener() {

                        @Override
                        public void onSkuDetailsResponse(int responseCode,
                                                         List<SkuDetails> skuDetailsList) {
                            listener.onSkuDetailsResponse(responseCode, skuDetailsList);
                        }

However, the responseCode is 0 and the list is also empty. But I checked onBillingSetupFinished is successful. The skuList that provided to SkuDetailsParams.Builder is not empty, and the values inside the skuList (sku_id) is also same as Product ID that specifies on Google Play Console.

Does anyone know the reason? Thanks!!

Hygrothermograph answered 17/10, 2017 at 4:13 Comment(2)
One problem can be if you are not running the signed apk wth the release keystore.Coverlet
I have the exact same problem . So hard to find the answer. I do not want to publis (even to beta) unfinished app and get it reviewed by GoogleFete
C
14

Sounds like you're having issues with your Google Play Console setup.

Please check that:

  • your app is published in Play Console (to PROD or your @gmail account is in the user's alpha/beta group)
    • I also recommend adding your test @gmail account into license testers list to avoid being charged and license issues
  • has correct signature and version code of test app is equal to published one
  • all of your SKUs are also published
  • your Play Store app works correctly on the phone you're testing (allows you to purchase apps for example)

And wait for some time after setup is done.

Confer answered 19/10, 2017 at 1:27 Comment(4)
Thanks!! Finally, I can query those items, because I hadn't put the app to Play Console and just tested with release apk. But I quite curious that why the code lab sample (codelabs.developers.google.com/codelabs/play-billing-codelab) can query in-app products directly without making the app release in the Play Console.Hygrothermograph
Is it necessity to have your unfinished app published just to test out your in app purchase? Is it necessity for Google to review your unfinished app just so you can test out in app purchases? That seems to make no sense. You should be able to test out in app purchases without publishing it. So I do not know if this answer is correct or Google just made this defect.Fete
Google is a one big deffect - they deleted my app with only internal testing apk - exactly for iap purposes, because it has (disabled) ad library inside which imho didn't pay for not being banned by Google. So yes you have to have apk published for testing, and yes they will ban your app if they want, even internal.Holeproof
In my case, I really need to wait for some time after the subscriptions were activated to get them in my appSkillern
S
15

I also had the same problem, but by doing the following, I got SkuDetails.

  • Stop Google Play app
  • Delete cache of Google Play app
  • Stop the application and start it
Saga answered 9/11, 2018 at 7:52 Comment(3)
This solve a lot problems, I added a new sku in the google console and it not appeared until I deleted the cache of google play app!Sweven
Solved my issue too.Chimpanzee
Why "Stop Google Play app"?Sladen
T
15

I have spent few hours with this issue and the problem was that my debug build/CI builds had applicationIdSuffix. So only production build with proper applicationId was able to retrieve the products.

Theravada answered 15/12, 2018 at 17:11 Comment(2)
Can you please explain, where it is?Maturity
It could be in your app/build.gradle file - android & buildTypes section.Theravada
C
14

Sounds like you're having issues with your Google Play Console setup.

Please check that:

  • your app is published in Play Console (to PROD or your @gmail account is in the user's alpha/beta group)
    • I also recommend adding your test @gmail account into license testers list to avoid being charged and license issues
  • has correct signature and version code of test app is equal to published one
  • all of your SKUs are also published
  • your Play Store app works correctly on the phone you're testing (allows you to purchase apps for example)

And wait for some time after setup is done.

Confer answered 19/10, 2017 at 1:27 Comment(4)
Thanks!! Finally, I can query those items, because I hadn't put the app to Play Console and just tested with release apk. But I quite curious that why the code lab sample (codelabs.developers.google.com/codelabs/play-billing-codelab) can query in-app products directly without making the app release in the Play Console.Hygrothermograph
Is it necessity to have your unfinished app published just to test out your in app purchase? Is it necessity for Google to review your unfinished app just so you can test out in app purchases? That seems to make no sense. You should be able to test out in app purchases without publishing it. So I do not know if this answer is correct or Google just made this defect.Fete
Google is a one big deffect - they deleted my app with only internal testing apk - exactly for iap purposes, because it has (disabled) ad library inside which imho didn't pay for not being banned by Google. So yes you have to have apk published for testing, and yes they will ban your app if they want, even internal.Holeproof
In my case, I really need to wait for some time after the subscriptions were activated to get them in my appSkillern
C
7

The core problem is that Google caches your SKU details, and there are multiple layers of cache.

The local Google Play Store app on your phone caches SKU details, and Google's server-side caches them, too. ("There are only two hard things in Computer Science: cache invalidation and naming things.")

Eventually, if you wait long enough, the caches will expire and Google will start showing the right information. But who has time for that?

Since there's a time element involved, it it's hard to know what helps and what doesn't, but here's what worked for me.

  1. Set up a version of your APK on the Internal Test track. (The first time you do this, you'll have to wait for your app to finish "Pending Publication." The waiting itself may solve the problem.)

    Set up at least one tester, get the opt-in link (this requires waiting for your app to finish "Pending Publication"), and opt-in.

  2. Force stop and delete the cache of the Google Play Store app, using the "Apps" section of the Settings app. Click on "Storage" to access the "Clear Cache" button.

  3. Download a version of the app via the Internal Test track. Use android.util.Log to log your SKU details, and use Logcat to verify that your SKU details are showing correctly.

… but don't worry, you won't have to do this every time you want to test. Once the Google Play Store cache is up to date, you should be able to access your SKUs in debug builds using Android Studio.

If it doesn't work in your Internal Test build

  1. Uninstall the app, force stop the Google Play Store app, clear its cache, and download the Internal Test build again.
  2. Still not working? Something's wrong in your Google Play Developer Console. Perhaps your product is not yet active? Perhaps you misspelled the SKU in your SKU list?

If it works in your Internal Test build but doesn't work in a debug build on the same device

In this case, the Google Play Store cache is correct, but there's something different about your debug build vs. the Internal Test version you created.

  1. Verify that your debug build is using the same package name as the Internal Test build. applicationIdSuffix is a common culprit here.
  2. Verify that your debug build version code matches the APK version code you uploaded to Internal Test.
  3. Try manually installing your Internal Test APK without using the Google Play Store. If that works, you have two APKs, one of which works, and one of which doesn't. Inspect them for differences. (APKs are zip files; you can poke around in there.)
Charissacharisse answered 25/5, 2019 at 1:58 Comment(0)
C
4

If the product integrated in the application is a subscription make sure to set SkuType.SUBS and not SkuType.INAPP

val skuDetailsParams = SkuDetailsParams.newBuilder()
    ...
    .setType(SkuType.SUBS)
    .build()

GL

Source

Central answered 5/8, 2019 at 20:26 Comment(0)
M
1

You don't need to upload your apk.

You should be getting skus. The BillingClient should work even if you test it in debug mode.

Make sure the products or subscriptions are active.

Give it some time. It could take a couple hours for the billing process to update your products.

Mccartan answered 7/7, 2018 at 14:41 Comment(2)
It took almost a day for me to get the additional subscriptions appear on android. I had already one working Managed Product setup on the console in live application.Quotha
All my subscriptions are active. I gave over 24 hours. Still SKUDetailsList has 0 object whenever I query querySkuDetailsAsync. I haven't published my app.Fete
K
1

Your app must be approved in Google Play store, this can take up to 1 week

Karissakarita answered 26/3, 2020 at 11:33 Comment(2)
you need your unfinished app to be reviewed and approved by Google just so you can test out in app purchase? Makes no sense.Fete
Yes makes no sence but this is the case anywayMorentz
D
0

In addition to previous answers, SkuDetailsList could be empty when you execute the search without Internet Connection. So you have to manage that situation in your code too.

Dimissory answered 29/11, 2019 at 17:13 Comment(0)
E
0

This can also happen for users in countries where in-app purchases are not available (Cuba, China, etc)

Check country status in Pricing & distribution section from play console

Evermore answered 4/3, 2020 at 20:49 Comment(0)
B
0

For later googler, my problem is I used an account that can not pay for my testing app. When I switch my google account on the test device, all the information came as expected. To quickly if the account has ability to pay, try to open the "top paid" chart in google play store, if the list is empty, this account definitely is not going to work, not matter what.

Spent days to track down this problem.

Barratry answered 11/4, 2023 at 2:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.