Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.UnsatisfiedLinkError on Android #45

Closed
Raptorhugo opened this issue May 20, 2016 · 4 comments
Closed

java.lang.UnsatisfiedLinkError on Android #45

Raptorhugo opened this issue May 20, 2016 · 4 comments

Comments

@Raptorhugo
Copy link

Raptorhugo commented May 20, 2016

HI, sorry for my english. I'm trying to use jSerialComm.jar in my android project.
Device is Android 4.4.2 with phisical serial ports (no usb to rs232)

In my build.grandle i've set
compile 'com.fazecast:jSerialComm:1.3.11'

than in app/src/main I've created jniLibs with structure and .so files.

in mainActivity

System.loadLibrary("jSerialComm"); //no errors
SerialPort[]    sp= null;
try
 {
    sp= SerialPort.getCommPorts(); //error !!!!
 }
catch(Exception ex)
{
 ex.printStackTrace();
 }

When start project on device i run into an error:
java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.apiciolabs.easycash/cache/1463764816989-libjSerialComm.so" is too small to be an ELF executable at java.lang.Runtime.load(Runtime.java:333) at java.lang.System.load(System.java:512) at com.fazecast.jSerialComm.SerialPort.<clinit>(SerialPort.java:181) at com.apiciolabs.easycash.ControlApplication.onCreate(ControlApplication.java:192) at com.android.tools.fd.runtime.BootstrapApplication.onCreate(BootstrapApplication.java:326) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325) at android.app.ActivityThread.access$1400(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1457) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4998) 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:811) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:627) at dalvik.system.NativeStart.main(Native Method)

in data/data/com.apiciolabs.easycash/cache/1463764816989-libjSerialComm.so is 0 byte. I can't understand what is wrong . Can you help me please?
Best regards

@agur
Copy link

agur commented Oct 26, 2016

Getting the same issue and the file is 0 size too:

u0_a42@klteatt:/data/data/berserker.android.apps.sshdroid/home/dl $ date && ll /data/data/com.hoho.android.usbserial.examples/cache/1477522065592-libjSerialComm.>
Wed Oct 26 22:48:47 GMT 2016
-rw-------    1 app_351  app_351          0 Oct 26 22:47 /data/data/com.hoho.android.usbserial.examples/cache/1477522065592-libjSerialComm.so
u0_a42@klteatt:/data/data/berserker.android.apps.sshdroid/home/dl $

I have seen a similar challange before, where the apk would have the OSx and Win binary libs but not the android one, despite having the android one baked in the jar properly next to the others.

My Android version is 4.4.2.

10-26 16:01:30.466 31419-31419/com.hoho.android.usbserial.examples E/AndroidRuntime: 
    FATAL EXCEPTION: main
    Process: com.hoho.android.usbserial.examples, PID: 31419
    java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.hoho.android.usbserial.examples/cache/1477522883565-libjSerialComm.so" is too small to be an ELF executable
        at java.lang.Runtime.load(Runtime.java:333)
        at java.lang.System.load(System.java:512)
        at com.fazecast.jSerialComm.SerialPort.<clinit>(SerialPort.java:181)
        at com.hoho.android.usbserial.examples.SerialConsoleActivity.onResume(SerialConsoleActivity.java:192)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1198)
        at android.app.Activity.performResume(Activity.java:5530)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2959)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2998)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
        at android.app.ActivityThread.access$900(ActivityThread.java:169)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5476)
        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:1268)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
        at dalvik.system.NativeStart.main(Native Method)

And yes:

System.loadLibrary("jSerialComm"); //no errors

does not error out - good point, thanks.

There is a difference between the calls to System.load and System.loadLibrary
Will keep debugging into it.

Also, this may be similar to #36 jSerialComm on Android. I have also updated the library code to resolve that issue, though used another method. Have then included the jar and sources jar in the libs/ folder and included with compile files('libs/jSerialComm-1.3.13.1-SNAPSHOT.jar'). If things do work properly, I may later publish conclusions if finding the time for it.

@adityagoel19
Copy link

Hi, were you able to find solution to this? I am facing the same problem. Android version 4.4.2

@agur
Copy link

agur commented May 17, 2017

Was not doing much Android later on.

@hedgecrw hedgecrw changed the title java.lang.UnsatisfiedLinkError java.lang.UnsatisfiedLinkError on Android Apr 3, 2018
@hedgecrw
Copy link
Contributor

Closing this (with external reference) in favor of a new single issue to address the several very similar Android-based problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants