question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

querySkuDetailsAsync Listener calls in wrong thread

See original GitHub issue

I have just recently updated the latest version of the Google Billing Lib. 4.1.0 from 3.0.2. I don’t know how exactly to define this issue but will try my best. Now what I noticed when I call querySkuDetailsAsync with the listener and inside this listener, I am printing products SKUs prices to the device screen, In the newer version, an exception was thrown like Only the original view can touch its view hierarchy as you can notice it’s like the listener just went to a background thread or its code execution is happening in the background thread. Now you say it might be my code has something to do with it BUT actually, it’s not… As I have downgraded to the older version its working fine with the same source code… So it’s not really a source code problem but something with a newer version of the library.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
gomigbgcommented, Aug 1, 2022

I think that this is actually a bug. The documentation for BillingClient says All methods annotated with [AnyThread](https://developer.android.com/reference/androidx/annotation/AnyThread) can be called from any thread and all the asynchronous callbacks will be returned on the same thread. Methods annotated with [UiThread](https://developer.android.com/reference/androidx/annotation/UiThread) should be called from the Ui thread and all the asynchronous callbacks will be returned on the Ui thread as well. (https://developer.android.com/reference/com/android/billingclient/api/BillingClient)

And querySkuDetailsAsync is marked AnyThread, so I would expect that if you call it on the UiThread, then the callback would be called on the UiThread.

0reactions
grog444commented, Nov 18, 2022

Why is this issue closed? The documentation should be updated from

All methods annotated with AnyThread can be called from any thread and all the asynchronous callbacks will be returned on the same thread

to

All methods annotated with AnyThread can be called from any thread and all the asynchronous callbacks will be returned on some single thread that may or may not be the calling thread.

Since that’s what I’m forced to assume it means.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Billing 4.0.0 - No purchase result ... - Stack Overflow
Following @Maasaivatar's answer, it works after running the SkuDetailsResponseListener on the main thread: billingClient.querySkuDetailsAsync( ...
Read more >
BillingClient - Android Developers
Main interface for communication between the library and user application code. It provides convenience methods for in-app billing.
Read more >
FetchAdditionalProducts() can be very slow - Unity Forum
public class IAPSystem : MonoBehaviour, IStoreListener ... We currently use querySkuDetailsAsync which is marked as deprecated The new call ...
Read more >
Exploring the Play Billing Library for Android | Joe Birch
Now that we have our params setup, we just need to call the querySkuDetailsAsync() method, passing in our parameters:.
Read more >
Implement the Google Play Billing Interface | In-App Purchasing
QueryProductDetailsAsync API; QuerySkuDetailsAsync API ... To receive updates on purchases, add a listener by calling setListener() .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found