Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.32k stars 280 forks source link

Issue when calling SerialPort[] serialPortsList = SerialPort.getCommPorts(); #445

Closed ChaseZebarth closed 2 years ago

ChaseZebarth commented 2 years ago

I am trying to use this code as a response to an event listener in Android Studio using Java. When I press the button to call the code, I get this: E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.tccccontrol1, PID: 6399 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.tccccontrol1-dc_mQ6Z3SFlILYfdTc-s_w==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.tccccontrol1-dc_mQ6Z3SFlILYfdTc-s_w==/lib/arm64, /system/lib64, /system/vendor/lib64]]] couldn't find "libjSerialComm.so" at java.lang.Runtime.loadLibrary0(Runtime.java:1012) at java.lang.System.loadLibrary(System.java:1669) at com.example.tccccontrol1.MainActivity$3.onClick(MainActivity.java:189) at android.view.View.performClick(View.java:6618) at android.widget.CompoundButton.performClick(CompoundButton.java:134) at android.view.View.performClickInternal(View.java:6590) at android.view.View.access$3100(View.java:781) at android.view.View$PerformClick.run(View.java:25950) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:215) at android.app.ActivityThread.main(ActivityThread.java:6952) 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:870)

I have read that this could have something to do with androids protections on ports, but I am hoping this is not the case as I don't want to have to root my device.

hedgecrw commented 2 years ago

That's correct - the current v2.X.X series of this library only works with rooted Android devices. The upcoming 3.X.X series will work on unrooted devices, but that is still a ways away from being released.

ChaseZebarth commented 2 years ago

Thanks for the quick response! Do you have a suggestion for a work around or something I should use instead? I know there are apps on google play that allow for serial communication to USB through OTG cables but I can't seem to figure out how they do it.

hedgecrw commented 2 years ago

Unfortunately, I don't know of any workarounds that mimic a serial port - most apps just directly use the Android USB interface to achieve serial communications. (It's honestly not that bad of an API...you might be able to use it to get up-and-running without too much of a headache). https://developer.android.com/reference/android/hardware/usb/package-summary

ChaseZebarth commented 2 years ago

Thanks! You've been a big help.