Android Question Native lib missing from apk

warwound

Expert
Licensed User
Hi all.

I have taken an old Eclipse JNI project, converted it into an Android Studio project, modified the C code and then tested it in an Android Studio test project - it works perfectly.

Next i wrapped the new JNI project into a b4a library, tested and got nothing but an UnsatisfiedLinkError, android cannot find my native library file libRfm73Streams.so:

** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (taskhost) Create ***
PlayerBufferSize: 2080
receivertask_initialize (java line: 51)
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/mycompany.api.fskstreams-1/base.apk"],nativeLibraryDirectories=[/data/app/mycompany.api.fskstreams-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libRfm73Streams.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at mycompany.api.rfm73.Rfm73.<clinit>(Rfm73.java:16)
at mycompany.api.rfm73.Rfm73$Rfm73Wrapper.Initialize(Rfm73.java:188)
at mycompany.api.fskstreams.receivertask._initialize(receivertask.java:51)
at mycompany.api.fskstreams.taskhost._service_create(taskhost.java:167)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at mycompany.api.fskstreams.taskhost.onCreate(taskhost.java:56)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877)
at android.app.ActivityThread.-wrap4(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:742)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
receivertask_initialize (java line: 51)
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/mycompany.api.fskstreams-1/base.apk"],nativeLibraryDirectories=[/data/app/mycompany.api.fskstreams-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libRfm73Streams.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at mycompany.api.rfm73.Rfm73.<clinit>(Rfm73.java:16)
at mycompany.api.rfm73.Rfm73$Rfm73Wrapper.Initialize(Rfm73.java:188)
at mycompany.api.fskstreams.receivertask._initialize(receivertask.java:51)
at mycompany.api.fskstreams.taskhost._service_create(taskhost.java:167)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at mycompany.api.fskstreams.taskhost.onCreate(taskhost.java:56)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877)
at android.app.ActivityThread.-wrap4(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:742)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
I'm compiling my wrapper using SLC and have a directory structure:

project-folder\additional\lib\armeabi-v7a\libRfm73Streams.so
project-folder\src\ <my classes here>

(armeabi-v7a is the only CPU architecture that i need to support, i use many other native libraries and the 'armeabi-v7a' variant is the one i always use on our custom android tablets).

SLC compiles my project and the library .jar contains:
<jar root folder>\lib\armeabi-v7a\libRfm73Streams.so

B4A compiles my test project and it throws the UnsatisfiedLinkError when started.
A quick check in the compiled .apk file shows no lib folder and no native library file.

So why isn't b4a compiling the library into the apk?

A forum search showed a similar problem from another member and the problem was caused by a mismatch of java package name in the native wrapper class - it didn't match the C function names.
Now i did refactor my library wrapper package name and C function names, i assume i have done this correctly as a test project in Android Studio worked fine.

How can i debug this problem?

Thanks.
 
Top