I just got started with NDK and am struggling to get the Hello-JNI sample running on Android Studio. I got it working using Eclipse but I'd prefer to have it running on Android Studio. I've poured through countless suggestions on how I should put the armeabi folder into a lib folder and pack that inside a jar (https://groups.google.com/forum/#!msg/adt-dev/nQobKd2Gl_8/Z5yWAvCh4h4J) but so far none of this has worked. It's getting quite frustrating. Does anyone have a working Hello-JNI sample that can be built and run from Android Studio and deployed on a device? I just need a working NDK sample project in Android Studio. Any help is appreciated, thanks guys.
This sample guides you through hello-jni, a minimal C/C++ application built with the NDK. This sample is in the hello-jni directory of ndk-samples repo, inside android-mk branch.
This sample is in the hello-jni directory of ndk-samples repo, inside android-mk branch. The following two lines provide the name of the native source file, along with the name of the shared library to build. The full name of the built library is libhello-jni.so, once the build system adds the lib prefix and the .so extension.
All you have to do is create a folder called "jniLibs" under your /src/main directory (ie, /app/src/main/jniLibs) and place your .so files there. It will look like this: Your .so files should be picked up now. Show activity on this post. There is other way to import so to the android project.
The hello-jni.c file is located in hello-jni/jni/. It contains a function that returns a string that the Java side requested ). The function declaration is as follows: This declaration corresponds to the native function declared in the Java source code.
As stated by Google, the Android Studio will start supporting NDK projects in it's version 5.0 (I can't find the source but will add it as soon as I get it). At the moment, the latest version is 3.1.
You can find a couple of workarounds on this thread
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With