I am writing an Android application. I am implementing some of the app in C++ using JNI. Is there a way to actually separate completely the JNI (C++) code from the Java Android code? Like creating a JNI project or something ? Because my C++ code will become a little library that I will use in another app. I tried to create a C++ project but I can’t compile with ndk-build.
Share
If you use JNI in your C++ code, then it’s bound to Android, and it must be an Android project with properly defined
Android.mk,Application.mk(optional).If you don’t use JNI API in your code, say you want to create a generic library, you can just write your C++ code, compile it, test it as usual, no
ndk-buildis needed. When you finish coding with the library, build the code as a static library, and when you want to use this static library in your Android project, write some JNI wrappers around functionalities in the static library that you want to use, link against the static library in yourAndroid.mk, something like this: