Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid UnsatisfiedLinkError: Issue loading a shared library
    text
    copied!<p>I am compiling some Java code, putting it into a .JAR and then running dx --dex on it. I am pushing my file to an Android device through adb but I am having problem linking my shared library at runtime.</p> <p>In HostConnection.java, I have the following code to load my library:</p> <pre><code>static { System.loadLibrary("hostConnection"); } </code></pre> <p>I am loading the application this way:</p> <pre><code>adb shell su export CLASSPATH=/data/local/device.jar export LD_LIBRARY_PATH=/data/local/libhostConnection.so exec app_process /system/bin com.device.client.Main </code></pre> <p>I am unfortunately getting the following error:</p> <pre><code>D/dalvikvm( 1616): DexOpt: load 482ms, verify 84ms, opt 10ms D/dalvikvm( 1608): DexOpt: --- END 'device.jar' (success) --- D/dalvikvm( 1608): DEX prep '/data/local/device.jar': unzip in 1715ms, rewrite 1287ms W/dalvikvm( 1608): Exception Ljava/lang/UnsatisfiedLinkError; thrown during Lcom/device/client/HostConnection;.&lt;clinit&gt; D/AndroidRuntime( 1608): Shutting down VM W/dalvikvm( 1608): threadid=1: thread exiting with uncaught exception (group=0x4001d830) I/Process ( 1608): Sending signal. PID: 1608 SIG: 9 E/AndroidRuntime( 1608): *** FATAL EXCEPTION IN SYSTEM PROCESS: main E/AndroidRuntime( 1608): java.lang.ExceptionInInitializerError E/AndroidRuntime( 1608): at com.device.client.Main.&lt;init&gt;(Main.java:27) E/AndroidRuntime( 1608): at com.device.client.Main.main(Main.java:21) E/AndroidRuntime( 1608): at com.android.internal.os.RuntimeInit.finishInit(Native Method) E/AndroidRuntime( 1608): at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235) E/AndroidRuntime( 1608): at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime( 1608): Caused by: java.lang.UnsatisfiedLinkError: Library hostConnection not found E/AndroidRuntime( 1608): at java.lang.Runtime.loadLibrary(Runtime.java:461) E/AndroidRuntime( 1608): at java.lang.System.loadLibrary(System.java:557) E/AndroidRuntime( 1620): at com.device.client.HostConnection.&lt;clinit&gt;(HostConnection.java:25) </code></pre> <p>The line 25 in HostConnection.java is indeed System.loadLibrary("hostConnection").</p> <p>My library is called libhostConnection.so and my .jar is called device.jar. They are both stored in /data/local. I have tried moving the shared library to /system/lib but the shell does not let me copy the file (read-only).</p> <p>I am not sure what I am doing wrong, but I believe it cannot find the shared library for linking when running the application. I am not sure if I am using the wrong variable in export, or if I am supposed to do something else.</p> <p>Could anyone please help me? It would be much appreciated.</p> <p>Thank you very much!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload