Unable to use a native android plugin for Unity

2019-09-16 19:01发布

I wish to use this native plugin for Android devices via Unity. For some reason the plugin is just now working. When I run it on a real device the game crashes. I am using Unity 5.5.2f1 personal, my phone is Samsung Edge 6 with Marshmallow api.

I have placed the jar file inside Assest/Plugins/Android. I can't figure out what is the cause for this error. Do you know what is wrong here?

This is part of my code:

 private AndroidJavaObject plugin;

void Start ()
{
    plugin = new AndroidJavaClass("jp.kshoji.unity.sensor.UnitySensorPlugin").CallStatic<AndroidJavaObject>("getInstance");

    //Init the ambienttemperature sensor
    if (plugin != null) 
    {
        plugin.Call("startSensorListening", "ambienttemperature");
    }

}

0条回答
登录 后发表回答