Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't libgnustl_shared.so being copied from my APK?

I have an android project with a libs folder structure like this:

/libs
  /armeabi
    libfoo.so
    libbar.so
    libmystuff.so
    libgnustl_shared.so
  /armeabi-v7a
    libfoo.so
    libbar.so

foo and bar are third party libraries, mystuff is my own library from a separate android JNI project which requires gnustl_shared, which is from the same JNI project.

When I build my project in Eclipse, I can view the contents of the generated APK using unzip -l, and it indeed shows that all of these library files have been included.

However, after installing the APK, the /data/data/com.myproject/lib folder contains no libgnustl_shared.so, even though the other libraries are present.

This inevitably leads to the following error:

UnsatisfiedLinkError: Couldn't load gnustl_shared: findLibrary returned null

As a sanity check, I ran adb push ./libs/armeabi/libgnustl_shared.so /data/data/com.myproject/lib and sure enough, the application starts as expected.

I don't see anything in the build log or Eclipse console that suggests there were any issues building or installing the app.

  • What could be preventing libgnustl_shared.so from being installed with my application?
  • Where can I go to learn about what happens when an APK is installed?

Please let me know in a comment if there's any specific information I can provide that might help.

like image 393
namuol Avatar asked Apr 22 '13 12:04

namuol


1 Answers

I think that, in your JNI project's Android.mk file, most probably, when you build libmystuff.so, you're referencing libgnustl_shared.so like:

LOCAL_LDLIBS += -lgnustl_shared

Maybe you can try to add it as a module (NDK works really focused on modules), something like:

include $(CLEAR_VARS) 
LOCAL_MODULE := gnustl_shared 
LOCAL_SRC_FILES := libgnustl_shared.so
include $(PREBUILT_SHARED_LIBRARY)

and (in the section you're building libmystuff.so):

LOCAL_SHARED_LIBRARIES := gnustl_shared

And check if it's finally copied

like image 171
jcm Avatar answered Sep 21 '22 08:09

jcm