You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that Android Studio hasn't figured out how to ignore newer Java 9+ features, even though they aren't required for this library to work. Until that is resolved, you can use the following as a workaround in your Android gradle.build file:
If it already includes a 'configurations' section, add the word 'repackage' to its list of arguments. If it does not include a 'configurations' section, add the following code to gradle.build somewhere above the 'dependencies' section:
configurations {
repackage
}
In the 'dependencies' section, remove any lines you currently have referencing jSerialComm, and replace them with:
Save and rebuild your project, and it should automatically remove any Java 9 features from the library such that it can be successfully built and used in your Android application.
I removed the jar and so files I had downloaded and added
compile 'com.fazecast:jSerialComm:[2.0.0,3.0.0)'
to the end of my dependencies in the build.gradle files and added
import com.fazecast.jSerialComm.*;
to my MainActivity.java
It now builds!!
But it crashes... Do I have to install the .so file somewhere an my Android Oreo 8.1?
Debugging I see the following:
libraryPath="Android/arm64-v8a"
fileName=libjSerialComm.so
It seems to lock on the following line:
InputStream fileContents = SerialPort.class.getResourceAsStream("/" + libraryPath + "/" + fileName);
I think the .so files are not being used correctly?
Please help???
2018-09-24 23:11:09.458 16045-16045/com.xxxx.xxxx.demo E/zygote64: No implementation found for com.fazecast.jSerialComm.SerialPort[] com.fazecast.jSerialComm.SerialPort.getCommPorts() (tried Java_com_fazecast_jSerialComm_SerialPort_getCommPorts and Java_com_fazecast_jSerialComm_SerialPort_getCommPorts__)
2018-09-24 23:11:09.458 16045-16045/com.xxxx.xxxx.demo D/AndroidRuntime: Shutting down VM
--------- beginning of crash
2018-09-24 23:11:09.461 16045-16045/com.xxxx.xxxx.demo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxxx.xxxx.demo, PID: 16045
java.lang.UnsatisfiedLinkError: No implementation found for com.fazecast.jSerialComm.SerialPort[] com.fazecast.jSerialComm.SerialPort.getCommPorts() (tried Java_com_fazecast_jSerialComm_SerialPort_getCommPorts and Java_com_fazecast_jSerialComm_SerialPort_getCommPorts__)
at com.fazecast.jSerialComm.SerialPort.getCommPorts(Native Method)
at com.xxxxxxxx.demo.MainActivity.getPortNames(MainActivity.java:54)
at com.xxxx.xxxx.demo.MainActivity.onCreate(MainActivity.java:439)
at android.app.Activity.performCreate(Activity.java:6999)
at android.app.Activity.performCreate(Activity.java:6990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Reacted by ericzhang, Anatoliy Petrov, Jay Ko and Lusct
02-08 12:58:10.996 14495-14495/com.hasar.hasarmposdriver W/System.err: Could not locate or access the native jSerialComm shared library.
If you are using multiple projects with interdependencies, you may need to fix your build settings to ensure that library resources are copied properly.
02-08 12:58:12.518 14495-14495/com.hasar.hasarmposdriver W/dalvikvm: No implementation found for native Lcom/fazecast/jSerialComm/SerialPort;.openPortNative:()J
02-08 12:58:20.942 14495-14495/com.hasar.hasarmposdriver D/AndroidRuntime: Shutting down VM
02-08 12:58:20.942 14495-14495/com.hasar.hasarmposdriver W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41682ba8)
02-08 12:58:20.962 14495-14495/com.hasar.hasarmposdriver E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.hasar.hasarmposdriver, PID: 14495
java.lang.UnsatisfiedLinkError: Native method not found: com.fazecast.jSerialComm.SerialPort.openPortNative:()J
at com.fazecast.jSerialComm.SerialPort.openPortNative(Native Method)
at com.fazecast.jSerialComm.SerialPort.openPort(SerialPort.java:426)
at com.fazecast.jSerialComm.SerialPort.openPort(SerialPort.java:446)
at com.fazecast.jSerialComm.SerialPort.openPort(SerialPort.java:459)
at com.hasar.icard.pinpad.serial.SerialConnectorJSerialComm.open(SerialConnectorJSerialComm.java:43)
at com.hasar.icard.pinpad.serial.SerialConnectorJSerialComm.(SerialConnectorJSerialComm.java:30)
at com.hasar.hasarmposdriver.MainActivity$1.onClick(MainActivity.java:52)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5020)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
I encountered the same problem, and I finally found a workaround solution.
First, before you try repackaging, please make sure you install NDK tools because jSerialComm contains native codes.
Second, after adding the repackaging Gradle script into your project, you need to satisfy linking by adding shared libraries, ".so" files, into JNI source directories.
Activity
ofer commentedon Jul 11, 2018
Same here, any ideas / solution?
This happens using android studio, adding a java module, adding a dependency jSerialComm:
implementation 'com.fazecast:jSerialComm:2.0.2'
ofer commentedon Jul 13, 2018
Downgrading to 1.3.11 works.
hedgecrw commentedon Jul 31, 2018
It appears that Android Studio hasn't figured out how to ignore newer Java 9+ features, even though they aren't required for this library to work. Until that is resolved, you can use the following as a workaround in your Android gradle.build file:
If it already includes a 'configurations' section, add the word 'repackage' to its list of arguments. If it does not include a 'configurations' section, add the following code to gradle.build somewhere above the 'dependencies' section:
In the 'dependencies' section, remove any lines you currently have referencing jSerialComm, and replace them with:
such that your 'dependencies' section has a form similar to:
Finally, add the following code to the very bottom of your gradle.build file:
Save and rebuild your project, and it should automatically remove any Java 9 features from the library such that it can be successfully built and used in your Android application.
ChadWagner commentedon Sep 24, 2018
Did not work for me?
Any suggestions?
hedgecrw commentedon Sep 24, 2018
Simply delete the 'module-info.class' file from the jSerialComm JAR file (opened using a zip file editor). This is an Android Studio issue.
ChadWagner commentedon Sep 24, 2018
Getting closer....
Program type already present: com.fazecast.jSerialComm.SerialPort$SerialPortEventListener$1
Message{kind=ERROR, text=Program type already present: com.fazecast.jSerialComm.SerialPort$SerialPortEventListener$1, sources=[Unknown source file], tool name=Optional.of(D8)}
Any suggestions?
ChadWagner commentedon Sep 24, 2018
I removed the jar and so files I had downloaded and added
compile 'com.fazecast:jSerialComm:[2.0.0,3.0.0)'
to the end of my dependencies in the build.gradle files and added
import com.fazecast.jSerialComm.*;
to my MainActivity.java
It now builds!!
But it crashes... Do I have to install the .so file somewhere an my Android Oreo 8.1?
Debugging I see the following:
libraryPath="Android/arm64-v8a"
fileName=libjSerialComm.so
It seems to lock on the following line:
InputStream fileContents = SerialPort.class.getResourceAsStream("/" + libraryPath + "/" + fileName);
I think the .so files are not being used correctly?
Please help???
2018-09-24 23:11:09.458 16045-16045/com.xxxx.xxxx.demo E/zygote64: No implementation found for com.fazecast.jSerialComm.SerialPort[] com.fazecast.jSerialComm.SerialPort.getCommPorts() (tried Java_com_fazecast_jSerialComm_SerialPort_getCommPorts and Java_com_fazecast_jSerialComm_SerialPort_getCommPorts__)
2018-09-24 23:11:09.458 16045-16045/com.xxxx.xxxx.demo D/AndroidRuntime: Shutting down VM
2018-09-24 23:11:09.461 16045-16045/com.xxxx.xxxx.demo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxxx.xxxx.demo, PID: 16045
java.lang.UnsatisfiedLinkError: No implementation found for com.fazecast.jSerialComm.SerialPort[] com.fazecast.jSerialComm.SerialPort.getCommPorts() (tried Java_com_fazecast_jSerialComm_SerialPort_getCommPorts and Java_com_fazecast_jSerialComm_SerialPort_getCommPorts__)
at com.fazecast.jSerialComm.SerialPort.getCommPorts(Native Method)
at com.xxxxxxxx.demo.MainActivity.getPortNames(MainActivity.java:54)
at com.xxxx.xxxx.demo.MainActivity.onCreate(MainActivity.java:439)
at android.app.Activity.performCreate(Activity.java:6999)
at android.app.Activity.performCreate(Activity.java:6990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
ChadWagner commentedon Sep 25, 2018
Should the versions be arm64-v8a?
ChadWagner commentedon Sep 25, 2018
My .apk file includes OSX and Windows but not Android. What have I done wrong?
mtotaro commentedon Feb 8, 2019
I cant open port in android studio
02-08 12:58:10.996 14495-14495/com.hasar.hasarmposdriver W/System.err: Could not locate or access the native jSerialComm shared library.
If you are using multiple projects with interdependencies, you may need to fix your build settings to ensure that library resources are copied properly.
02-08 12:58:12.518 14495-14495/com.hasar.hasarmposdriver W/dalvikvm: No implementation found for native Lcom/fazecast/jSerialComm/SerialPort;.openPortNative:()J
02-08 12:58:20.942 14495-14495/com.hasar.hasarmposdriver D/AndroidRuntime: Shutting down VM
02-08 12:58:20.942 14495-14495/com.hasar.hasarmposdriver W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41682ba8)
02-08 12:58:20.962 14495-14495/com.hasar.hasarmposdriver E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.hasar.hasarmposdriver, PID: 14495
java.lang.UnsatisfiedLinkError: Native method not found: com.fazecast.jSerialComm.SerialPort.openPortNative:()J
at com.fazecast.jSerialComm.SerialPort.openPortNative(Native Method)
at com.fazecast.jSerialComm.SerialPort.openPort(SerialPort.java:426)
at com.fazecast.jSerialComm.SerialPort.openPort(SerialPort.java:446)
at com.fazecast.jSerialComm.SerialPort.openPort(SerialPort.java:459)
at com.hasar.icard.pinpad.serial.SerialConnectorJSerialComm.open(SerialConnectorJSerialComm.java:43)
at com.hasar.icard.pinpad.serial.SerialConnectorJSerialComm.(SerialConnectorJSerialComm.java:30)
at com.hasar.hasarmposdriver.MainActivity$1.onClick(MainActivity.java:52)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5020)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Any ideas what im doing wrong?
kimitaka commentedon Nov 25, 2021
I encountered the same problem, and I finally found a workaround solution.
First, before you try repackaging, please make sure you install NDK tools because jSerialComm contains native codes.
Second, after adding the repackaging Gradle script into your project, you need to satisfy linking by adding shared libraries, ".so" files, into JNI source directories.
Sample Gradle task:
That is all for my workaround.
If you have any better ideas, please tell me.