Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

android - Google Play Billing: Unable to query certain products from Play Console

I'm trying to query all my in-app products using the GooglePlay Billing library but the skuDetailsList in querySkuDetailsAsync() seem to only show some products listed in the Play Console. And by some, I mean, it's only displaying those products that are directly added via the Console. BUT that's not how I want to add my products. Instead, I want to do it dynamically by using the AndroidPublisher library using the inappproducts.insert method. So far, I am able to successfully insert products to Play Console via this library BUT upon trying to query all my products, using querySkuDetailsAsync() in the client app, only those products that I had specifically added via the library doesn't show up in app for some very strange reason! I have added all my in-app product IDs to an array list and I've also tested and made sure that the product IDs are correct (matches the one in Google Play Console). Moreover, all my products are active and my app has already been published so it should work.

However, from what I have observed, only those products that I added directly from Play Console seem to get added to the skuDetailsList while the ones I inserted via the Android Publisher library doesn't load in app even though it's active and listed in the Play Console which is pretty odd. Here's a reference to the code I used for the client app.

SkuDetailsParams params = SkuDetailsParams.newBuilder()
                        .setType(INAPP)
                        .setSkusList(skuList)
                        .build();

billingClient.querySkuDetailsAsync(params,
            (billingResult, skuDetailsList) -> {
                System.out.println("size:"+skuDetailsList.size());
                if (billingResult.getResponseCode() != BillingClient.BillingResponseCode.OK) {
                    System.out.println(String.format("Unable to query sku details: %d - %s", billingResult.getResponseCode(), billingResult.getDebugMessage()));
                } else {
                    for (SkuDetails details: skuDetailsList) {
                        System.out.println("title -> "+details.getTitle());
                        System.out.println("description -> "+details.getDescription());
                        System.out.println("price -> "+details.getPrice());
                    }

                    setRecyclerView(skuDetailsList);
                }
            });

And this is the code I used to insert products to Google Play Console dynamically.

//insert new product
    InAppProductListing listing = new InAppProductListing();
    listing.setTitle("my product");
    listing.setDescription("this is a description");
    Map<String,InAppProductListing> mapListing = new HashMap<String, InAppProductListing>();
    mapListing.put("en-GB", listing);

    Inappproducts inappproducts = pub.inappproducts();
    InAppProduct product = new InAppProduct();
    product.setDefaultLanguage("en-GB");
    product.setPackageName(packageName);
    product.setSku(productID);
    product.setPurchaseType("managedUser");
    product.setListings(mapListing);
    Price price = new Price();
    price.setCurrency("INR");
    price.setPriceMicros("50000000");
    product.setDefaultPrice(price);
    product.setStatus("active");
            
    try {
        inappproducts.insert(product.getPackageName(), product).setAutoConvertMissingPrices(true).execute();
        System.out.println("Success");
    } catch (Exception e) {
        // TODO: handle exception
    }

It's been so long and I can't seem to find any resources/documentation on this issue. I've noticed that the products added via code seems to show up only hours later but the ones added from Console loads at once. Is this an issue with my code or could it, instead, be some issue with the library? Would really appreciate some help/advice on this issue!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...