Android NDK UnsatisfiedLinkError: findLibrary returned null - android-ndk

Since two days, I get this error :
java.lang.UnsatisfiedLinkError: Couldn't load MyCPPProject from loader dalvik.system.PathClassLoader[dexPath=/system/framework/com.google.android.maps.jar:/data/app/com.mypackage.myApp-3.apk,libraryPath=/data/app-lib/com.mypackage.myApp-3]: findLibrary returned null
I'd like to compile a project c ++ natively in android application.
The project compiles fine on another PC but not on mine.
I tried to create a new workspace, install another eclipse and plenty others solutions but it still does not compile.
How can I fix it ?
The android project generate myApp.apk but not myApp-3.apk.
[dexPath=/system/framework/com.google.android.maps.jar:/data/app/com.mypackage.myApp-3.apk,libraryPath=/data/app-lib/com.mypackage.myApp-3]
Why compiler try to load myApp-3.apk ?

I fixed this issue by creating armeabi inside libs folder. And copied the .so files into armeabi folder.

Related

Artoolkit source code file cannot execute successfully in Android Studio

I downloaded the Artoolkit SDK in https://github.com/artoolkit/artoolkit5
And there is a directory called AndroidStudioProjects, which can be directly opened by using android studio.
I have configured all the jdk, android sdk, ndk.
However, those projects all have the error like this:
E/art: dlopen("/data/app/org.artoolkit.ar.samples.ARMovie-1/lib/arm/libARMovieNative.so", RTLD_LAZY) failed: dlopen failed: could not load library "libcurl.so" needed by "libARMovieNative.so"; caused by library "libcurl.so" not found
The main problem is could not load library "libcurl.so" needed by "libARMovieNative.so".
Can anyone help me please?
First you have to execute
$NDK/ndk-build
in the directory AndroidStudioProjects/ARMovieProj/aRMovie/src/main/jni/
which creates the libraries for a couple of architectures.
If you have not already done so far you have to execute the build.sh in the android directory of artoolkit.
If you don't want to build for every architecture feel free to modify
android/jni/Application.mk
ARMovieProj/aRMovie/src/main/jni/Application.mk
to for example
APP_ABI := armeabi-v7a
Make sure the arMovie.gradle has got the following inside the android block
android.sources.main.jniLibs {
source {
srcDirs = ['src/main/libs']
}
}

NDK: How to reference native sources OUTSIDE Android project?

I'm using Android Studio 1.2.2 and just downloaded 1.3RC3, as it reputedly has full NDK support.
I have a working project while my .c / .h files remain in app/src/main/jni; however, I want them in AndroidProject/../common/src, i.e. outside the android project folder. How do I make this work?
To reiterate: this question is about EXTERNAL, NATIVE CODE; not importing external java!
This was so simple, I didn't think to even try it at first, but it worked at once:
android{
...
sourceSets.main.jni.srcDirs = ['../../common/test']
...
}
...which implies that the path is relative to AndroidProject/app.
A problem with this solution is that it is incompatible with a standalone Android.mk, since preventing Android.mk generation by gradle requires sourceSets.main.jni.srcDirs = [].

Android NDK: No rule to make target with MuPDF

I am using this link, the answer by star18bit, to integrate MuPDF with my Android project.
I am able to run the ndk-build that is inside the MuPDF's android folder. But when I copied all MuPDF's files to my own project, and ran ndk-build from my project's jni folder, it gives this error:
make: *** No rule to make target ../jni/fitz/base_context.c', needed by ../jni/fitz/base_context.o'. Stop.
Any help to resolve this would be greatly appreciated!
I am following this link as it is, i.e., using the mupdf version 1.2 and android ndk r8e
I was trying to build this on MAC, but gave up.
Finally I did it on Windows 7, encountered a lot of issues while doing it. So I made a tutorial for it, for other users so that they don't have to go through the pain that I went through!
Here's the link:
http://howtojava.net/tutorials/android/integrate-mupdf-with-android-in-windows-7

Android NDK app won't run

I've been trying to get started on adding native code to my android app so I've looked through a plethora of Android NDK tutorials all to no avail. I can't get any of the apps to run on my emulator or my Galaxy S3. I keep getting the same error: "Unfortunately, [AppName] has stopped working"
My ndk-build command works successfully and I get a .so file. I don't know what the .so file is supposed to look like. Here's mine
http://txt.do/klo0
it looks like gibberish to me but what do I know?
This is my logcat
http://txt.do/klod
In the Android NDK directory, there is a hello-jni example. Try to compile and run it, it works.
It's in the samples/hello-jni directory of your NDK, I have it in ~/android-ndk-r9d/samples/hello-jni. Copy ("import") it into your workspace and compile.
To generate the headers:
cd bin/classes
javah com.my.package.name.MyClassName
Note that the library is usually placed by ndk-build into the libs/something subdirectory of your project, for example, libs/armeabi-v7a, and the file jni/Application.mk specifies what something is, e.g.
APP_ABI := armeabi-v7a
or
APP_ABI := all
The library will be placed in your apk and installed in a subdirectory of your application's data folder.
System.loadLibrary("stuff"); // libstuff.so
will find it. (Note that if you run your app as a system app, that's a different story.)
A library built for a wrong target will not work.

Unresolved inclusion/objects when building native-audio example?

I just installed the latest android SDK and NDK. I want to get familiar with OpenSL so I started with the native-audio example project in ndk/samples and I'm having trouble with native-audio-jni.c file. Eclipse cannot resolve any of the include files and doesn't recognize any of the OpenSL definitions. Doesn't even know what NULL means. I can build the project but once I open the .c file (once the file runs through the parser) the project won't build any more.
Other people have had the same problems and many solutions exist but none of them works for the latest SDK.
How can I fix all these errors?

Resources