mobfox / SDK-Plugins

plugins from various frameworks to our SDK
2 stars 2 forks source link

Unity3D 5.3.4 java.lang.RuntimeException #3

Open rchallenger opened 7 years ago

rchallenger commented 7 years ago

Project under Unity3D 5.3.4, which includes mobfox-android-unity-plugin.jar won't initialize MobFox by calling ConnectToPlugin() method as the following exception will be thrown.

AndroidJavaException: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

It happens while executing the following lines:

using (AndroidJavaClass pluginClass = new AndroidJavaClass ( "com.mobfox.unity.plugin.MobFoxPlugin" ))
{
    if (pluginClass != null)
    {
        mobFoxPlugin = pluginClass.CallStatic<AndroidJavaObject> ( "instance" ); //this line causes exception
        mobFoxPlugin.Call ( "setContext", activityContext );
    }
}

Exception is thrown as soon as getting instance is called.

If we upgrade project to Unity3D 5.4.0 - everything will be OK.