Question

Why do I get the exception that "queryPurchases" is a non-existent method?

  • 30 August 2022
  • 3 replies
  • 497 views

Badge +3

Hello

I want to use billing client v4(Google) with purchases_flutter over 3.4.0 and flutter 3.1.1.

but “java.lang.NoSuchMethodError: No virtual method queryPurchases" occured at this code.

await Purchases.setup(publickey);

and stack trace is this.

D/[Purchases] - DEBUG(21733): ℹ️ API request started: GET /subscribers/oDNEWTpax9Xkz0FVC3tdoRzdPbh1/offerings
D/[Purchases] - DEBUG(21733): ℹ️ API request completed with status: GET /subscribers/oDNEWTpax9Xkz0FVC3tdoRzdPbh1/offerings 304
D/[Purchases] - DEBUG(21733): ℹ️ Requesting products from the store with identifiers: jp.kazushige.sato.suudoku.month1, jp.kazushige.sato.suudoku.month6, jp.kazushige.sato.suudoku.month12
D/[Purchases] - DEBUG(21733): ℹ️ Requesting products from the store with identifiers: jp.kazushige.sato.suudoku.month1, jp.kazushige.sato.suudoku.month6, jp.kazushige.sato.suudoku.month12
D/[Purchases] - DEBUG(21733): ℹ️ Querying purchases
E/AndroidRuntime(21733): FATAL EXCEPTION: Thread-11
E/AndroidRuntime(21733): Process: jp.kazushige.sato.suudoku, PID: 21733
E/AndroidRuntime(21733): java.lang.NoSuchMethodError: No virtual method queryPurchases(Ljava/lang/String;)Lcom/android/billingclient/api/Purchase$PurchasesResult; in class Lcom/android/billingclient/api/BillingClient; or its super classes (declaration of 'com.android.billingclient.api.BillingClient' appears in /data/app/~~QXhhaysmqhTSoVemfw98mQ==/jp.kazushige.sato.suudoku-JH2QFUYsyY55fD9UUgTEdw==/base.apk)
E/AndroidRuntime(21733): at com.revenuecat.purchases.google.BillingWrapper$queryPurchases$1.invoke(BillingWrapper.kt:383)
E/AndroidRuntime(21733): at com.revenuecat.purchases.google.BillingWrapper$queryPurchases$1.invoke(BillingWrapper.kt:53)
E/AndroidRuntime(21733): at com.revenuecat.purchases.google.BillingWrapper.withConnectedClient(BillingWrapper.kt:593)
E/AndroidRuntime(21733): at com.revenuecat.purchases.google.BillingWrapper.queryPurchases(BillingWrapper.kt:380)
E/AndroidRuntime(21733): at com.revenuecat.purchases.Purchases$updatePendingPurchaseQueue$1.run(Purchases.kt:1707)
E/AndroidRuntime(21733): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
E/AndroidRuntime(21733): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/AndroidRuntime(21733): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
E/AndroidRuntime(21733): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(21733): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(21733): at java.lang.Thread.run(Thread.java:923)
D/[Purchases] - DEBUG(21733): ℹ️ Products request finished for jp.kazushige.sato.suudoku.month1, jp.kazushige.sato.suudoku.month6, jp.kazushige.sato.suudoku.month12

I/Process (21733): Sending signal. PID: 21733 SIG: 9
Lost connection to device.

method “queryPurchases" is deprecated method at billing client v4.0 but can be used.

and the  method is obsolete in v5.0.

Looking at this stack trace, it appears as if the revenuecat library is referencing v5.

If it references v4, why does it raise an exception that the method does not exist?

thanks 


3 replies

Badge +3

this issue has resolved by myself

 

It was because a completely different plugin was referencing v5. After temporarily removing that plugin, the exception no longer occurred.

Userlevel 3
Badge +3

Glad you got it fixed. Do you mind sharing the name of the plugin you were using? That way other devs can remove it in case they have the same issue

Badge +3

Thank you, Cesar.

that plugin is in_app_purchase 2.0.1

 

Reply