NeuronRobotics / nrjavaserial

A Java Serial Port system. This is a fork of the RXTX project that uses in jar loading of the native code.
Other
345 stars 143 forks source link

Error under Android #151

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hello, I would like to use nrjavaserial under android, but I get the following error message:

E/Unity ( 2415): AndroidJavaException: java.lang.ExceptionInInitializerError E/Unity ( 2415): java.lang.ExceptionInInitializerError E/Unity ( 2415): at gnu.io.NRSerialPort.getAvailableSerialPorts(NRSerialPort.java:210) E/Unity ( 2415): at com.example.unity_plugin.UnityLog.trace(UnityLog.java:42) E/Unity ( 2415): at com.unity3d.player.UnityPlayer.nativeRender(Native Method) E/Unity ( 2415): at com.unity3d.player.UnityPlayer.c(Unknown Source) E/Unity ( 2415): at com.unity3d.player.UnityPlayer$c$1.handleMessage(Unknown Source) E/Unity ( 2415): at android.os.Handler.dispatchMessage(Handler.java:98) E/Unity ( 2415): at android.os.Looper.loop(Looper.java:135) E/Unity ( 2415): at com.unity3d.player.UnityPlayer$c.run(Unknown Source) E/Unity ( 2415): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.InputStream.read(byte[])' on a null object reference E/Unity ( 2415): at gnu.io.NativeResource.copyResource(NativeResource.java:213) E/Unity ( 2415): at gnu.io.NativeResource.inJarLoad(NativeResource.java:93) E/Unity ( 2415): at gnu.io.NativeResource.loadLib(NativeResource.java:109) E/Unity ( 2415): at gnu.io.NativeResource.load(NativeResource.java:85) E/Unity ( 2415): at gnu.io.SerialManager.(SerialManager.java:67) E/Unity ( 2415): at gnu.io.Seri

Should I install an additional library under android for this to work?

madhephaestus commented 4 years ago

Since this library loads a JNI it isn't detecting the correct OS or loading the correct binary. If you could use the debugger to give more information on how it is being detected maybe we could try to support it.

It also might be something to do with the bundling. we pull the jni dll's out of the jar and save them to a tmp directory. it may not be doing all that correctly.