Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Started getting java.lang.ClassNotFoundException: com.android.billingclient.api.PurchasesUpdatedListener

I’ve started getting an error when the Unity app runs on an Android device, on UnityPurchasing Initialize

Unity 2022.3.181, In App Purchasing 4.12.2, Target API 34

UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.android.billingclient.api.PurchasesUpdatedListener
at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine.AndroidJavaProxy..ctor (System.String javaInterface) [0x00000] in <00000000000000000000000000000000>:0 
at UnityEngine.Purchasing.GooglePurchaseUpdatedListener..ctor (UnityEngine.Purchasing.Interfaces.IGoogleLastKnownProductService googleLastKnownProductService, UnityEngine.Purchasing.Interfaces.IGooglePurchaseCallback googlePurchaseCallback, UnityEngine.Purchasing.Interfaces.IGooglePurchaseBuilder purchaseBuilder, UnityEngine.Purchasing.IGoogleCachedQueryProductDetailsService googleCachedQueryProductDetailsService, UnityEngine.Pur

I tried to add a custom proguard with -keep class com.android.billingclient.** {*; } but that didn't change anything

Any hints on how to fix it?

like image 415
Ilya Blokh Avatar asked May 21 '26 11:05

Ilya Blokh


2 Answers

Somehow (generated?) this was added to mainTemplate.gradle file

   // ** ADD THIS **
configurations.all {
    exclude group: 'com.android.billingclient', module: 'billing'
}

I removed this exclude command and the issue was solved.

like image 120
Ilya Blokh Avatar answered May 23 '26 05:05

Ilya Blokh


You seem to be using an outdated billing-client dependency, in combination with a billing implementation, which runs against a newer version of that library. This might be the result of a half-hearted update, where the library wasn't updated. Maybe you have that outdated library still somewhere in a local cache?

As the documentation states (the current version would be 7.0.0):

Reminder: By Aug 31, 2024, all new apps and updates to existing apps must use Billing Library version 6 or newer.

The changelog of the Unity package is not telling which version is contained.

like image 41
Martin Zeitler Avatar answered May 23 '26 05:05

Martin Zeitler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!