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!!

TheOska
  • 325
  • 1
  • 3
  • 11

10 Answers10

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
takahirom
  • 1,934
  • 2
  • 12
  • 21
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.

hrach
  • 2,443
  • 2
  • 26
  • 37
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.

goRGon
  • 4,402
  • 2
  • 43
  • 45
  • 2
    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 (https://codelabs.developers.google.com/codelabs/play-billing-codelab) can query in-app products directly without making the app release in the Play Console. – TheOska Oct 19 '17 at 11:59
  • 4
    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. – coolcool1994 Aug 16 '20 at 05:36
  • 2
    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. – Tertium Jun 24 '21 at 13:41
  • In my case, I really need to wait for some time after the subscriptions were activated to get them in my app – Cube Jul 20 '21 at 09:54
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.)
Dan Fabulich
  • 37,506
  • 41
  • 139
  • 175
3

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

Braian Coronel
  • 22,105
  • 4
  • 57
  • 62
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.

live-love
  • 48,840
  • 22
  • 240
  • 204
  • 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. – Adil Soomro Feb 19 '20 at 12:45
  • 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. – coolcool1994 Aug 16 '20 at 05:38
1

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

Josef Vancura
  • 1,053
  • 10
  • 18
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.

Pablo Alfonso
  • 2,317
  • 1
  • 18
  • 24
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

user5480949
  • 1,410
  • 1
  • 15
  • 22
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.

davyzhang
  • 2,419
  • 3
  • 26
  • 34