Unity IAP is not being initialized on some devices.

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.

private bool IsInitialized ()
    {
        // Only say we are initialized if both the Purchasing references are set.
        return controller != null && extensions != null;
    }

Above code is always returning false on some devices even after calling 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:

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

The stack trace does not look to be IAP related. If possible please provide the full device logs from an affected device How To - Capturing Device Logs on Android