Download downloaded Android library

I am trying to load a library that I created using the NDK standalone toolchain.

I built libGLmove.so and put it in the libs / armeabi of my Eclipse project

However, calling System.loadLibrary("GLmove") raises an UnsatisfiedLinkError

Any ideas on how to solve the problem or get Android to find my library? How does ndk-build package a library after it is built?

Edit: exact compilation flags:

/Users/thomas/Documents/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/darwin-x86/bin/arm-eabi-g++ --sysroot = / Users / thomas / Documents / android-ndk -r5b / platform / android-8 / arch-arm -march = armv7-a -mfloat-abi = softfp -mfpu = neon -Wl, - fix-cortex-a8 -fno-exceptions -fno-rtti - nostdlib -fpic - shared -o GLmove.so -O3

+4
source share
5 answers

You checked the resulting .APK file (use the zip utility to view / unlock it) to see if your library goes through the packaging? I am a little suspicious that this may not be so, because I notice that everything that is built into the "libs" folder in the project and on my build machine ends up in the "lib" (no 's) folder in the APK.

I would not be surprised if it turns out that the Eclipse build process does not pack any libraries that it does not know about. This, of course, is in contrast to what happens to resources that are simply packaged because they are in the right place.

If you find that your library is not in your APK file, I donโ€™t think you can just manually place it there, as it will not appear in the package manifest and will also violate any signing.

You did not mention whether the Eclipse project is an NDK project (right-click on the project, Android Tools-> Add Native Support). If not, I suspect you will need to do this in one, and then add your library to the Android.mk file as a dependency, not a target.

Or: you can try placing your library in / res in the project and use System.load () instead of System.loadLibrary () to load it. I admit that I never tried this myself, tho.

+4
source

I ran into this problem. What I had was wrong.

  • In the make file, I had the wrong LOCAL_SRC_FILES code.
  • In the source c file, I had the library name inside the method name

Java_com_my_namespace_libname_activity_methodName(JNIEnv* env, jobject _this) {
//Fancy Native Junk Here
}

As soon as I fixed these two things, re-launched ndk-build and updated the eclipse project with F5, and it started working.

+2
source

You did not specify a lot of details, but it may be that the created .so relies on a library that is not available in the version of the phone you are using.

I didnโ€™t find a way to tell the NDK which version of the Android SDK you are targeting, so there is no clear idea how this side should work, but it seems that it would be easy to bring, depending on the new version of the SDK, in your .so so that it does not load on all phones.

+2
source

Could you check the syntax and location of System.loadLibrary ("GLmove")

the call to System.loadLibrary should be in the static block of the Java source file

 static { System.loadLibrary("nativelib"); } 

http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jniexamp.html

+1
source

If your native library needs other libraries, you need to download them first. If this does not help, make sure your project directory does not contain spaces.

In addition, you may find this tutorial useful: http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/

+1
source

All Articles