Search code examples
androidunity-game-enginein-app-purchasegame-development

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?


Solution

  • 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.