google / play-unity-plugins

The Google Play Plugins for Unity provide C# APIs for accessing various Play services
Other
440 stars 113 forks source link

java.lang.IllegalArgumentException: SKU must be set #67

Closed ahmad4zan closed 3 years ago

ahmad4zan commented 4 years ago

Hi, Im trying to upgrade to google play billing but i'm stuck at this error.

2020-11-10 22:13:01.505 19469-19566/? E/Unity: AndroidJavaException: java.lang.IllegalArgumentException: SKU must be set.
    java.lang.IllegalArgumentException: SKU must be set.
        at com.android.billingclient.api.zzap$zza.zza(com.android.billingclient:billing@@3.0.1:5)
        at com.android.billingclient.api.BillingClientImpl.querySkuDetailsAsync(com.android.billingclient:billing@@3.0.1:329)
        at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
        at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
        at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:237)
        at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
      at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 
      at UnityEngine.AndroidJavaObject._Call (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0 
      at System.Action`1[T].Invoke (T obj) [0x00000] in <000000000000000000000000000000

Im using the the standard Unity IAP plugin but changed the builder to Google.Play.Billing.GooglePlayStoreModule based on this https://developer.android.com/google/play/billing/unity#behavior-changes

This is my code of initializing.

public void InitializePurchasing() 
    {
        if (IsInitialized())
        {
            return;
        }
        var builder = ConfigurationBuilder.Instance(Google.Play.Billing.GooglePlayStoreModule.Instance());
        //var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
        builder.AddProduct(monthID, ProductType.Subscription);
        . . .

        UnityPurchasing.Initialize(this, builder);
    }

This never happend with the previous Unity IAP module. Please help!

mdobele commented 3 years ago

I ran into this error myself recently which stumped me for a bit until I realised it was due to a silly mistake I'd made.

Basically where we are adding our IAP productIDs I was passing in a blank string. builder.AddProduct(productID, ProductType.Subscription);

Check your "monthID" and make sure it's not an empty string.

Qing451800 commented 3 years ago

Good to know. Thanks for the update.

boeckxniels commented 1 year ago

I ran into this error myself recently which stumped me for a bit until I realised it was due to a silly mistake I'd made.

Basically where we are adding our IAP productIDs I was passing in a blank string. builder.AddProduct(productID, ProductType.Subscription);

Check your "monthID" and make sure it's not an empty string.

Same error Same fix thanks