Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hello-JNI for Android Studio [closed]

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.

like image 600
cbbcloud Avatar asked Oct 04 '13 12:10

cbbcloud


People also ask

What is Hello-JNI?

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.

Where can I find Hello-JNI sample files?

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.

How to import jnilibs to Android project?

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.

Where can I find JNI in Java?

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.


1 Answers

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

like image 88
XGouchet Avatar answered Oct 05 '22 13:10

XGouchet