Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity IAP is not being initialized on some devices.

Discussion in 'Unity IAP' started by reddy36996, Mar 15, 2019.

  1. reddy36996

    reddy36996

    Joined:
    Jan 10, 2016
    Posts:
    19
    Hi,
    I'm using Unity 2018.3.5f1 with Unity IAP 1.20.1

    In all our devices that we have with us and in editor as well, Unity IAP is working fine. We are also getting payments from live users successfully, until we checked the logs on server which is tracked whenever any purchase is made. We didn't see this data in play Console as purchase never went through but from logs we came to know that In-app is not being initialized in some devices.

    Also we think this is device specific as once we saw this happening to some user. Same user tried to purchase many times over the week but purchase was never successful. Also it is effecting more than half of our user base.

    Code (CSharp):
    1. private bool IsInitialized ()
    2.     {
    3.         // Only say we are initialized if both the Purchasing references are set.
    4.         return controller != null && extensions != null;
    5.     }
    Above code is always returning false on some devices even after calling
    Code (CSharp):
    1. UnityPurchasing.Initialize (this, builder);
    Also we came across some crashes that might be related to In-app not being initialized. Submitted logs from 2 such devices, please have a look:

    Code (CSharp):
    1.  
    2. Today, 4:23 AM on app version 45
    3. Samsung Galaxy S9+ (star2lte), Android 9
    4. Report 1 of 2
    5. java.lang.RuntimeException:
    6.   at android.app.ActivityThread.handleReceiver (ActivityThread.java:3546)
    7.   at android.app.ActivityThread.access$1300 (ActivityThread.java:235)
    8.   at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1779)
    9.   at android.os.Handler.dispatchMessage (Handler.java:106)
    10.   at android.os.Looper.loop (Looper.java:214)
    11.   at android.app.ActivityThread.main (ActivityThread.java:6981)
    12.   at java.lang.reflect.Method.invoke (Native Method)
    13.   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
    14.   at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1445)
    15. Caused by: java.lang.ClassNotFoundException:
    16.   at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134)
    17.   at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
    18.   at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
    19.   at android.app.AppComponentFactory.instantiateReceiver (AppComponentFactory.java:84)
    20.   at android.app.ActivityThread.handleReceiver (ActivityThread.java:3539)
    Code (CSharp):
    1.  
    2. Today, 6:29 AM on app version 45
    3. Sony Xperia XA2 (H3123), Android 8.0
    4. Report 1 of 1
    5. java.lang.RuntimeException:
    6.   at android.app.ActivityThread.handleReceiver (ActivityThread.java:3244)
    7.   at android.app.ActivityThread.-wrap17 (Unknown Source)
    8.   at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1685)
    9.   at android.os.Handler.dispatchMessage (Handler.java:105)
    10.   at android.os.Looper.loop (Looper.java:164)
    11.   at android.app.ActivityThread.main (ActivityThread.java:6590)
    12.   at java.lang.reflect.Method.invoke (Native Method)
    13.   at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240)
    14.   at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:767)
    15. Caused by: java.lang.ClassNotFoundException:
    16.   at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:93)
    17.   at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
    18.   at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
    19.   at android.app.ActivityThread.handleReceiver (ActivityThread.java:3239)
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446