While the editor of choice regarding C++ for Android* right now is eclipse*, Android Studio is starting to integrate the NDK as well.
C/C++ code edition isn’t well supported yet by Android* Studio but gradle can now make calls to the NDK directly. This integration allows you to get rid of Makefile to set everything in build.gradle, and the built-in feature of build flavors and variants is really worth it especially if you’re building one APK per CPU architecture. This screencast will give you an in-depth view of how this integration works by integration C/C++ code into your Android app or library and use build flavors to generate APKs tailored for each CPU architecture. An equivalent of this content for eclipse can be found here: http://software.intel.com/en-us/android/articles/using-the-android-x86-ndk-with-eclipse-and-porting-an-ndk-sample-app
Comments (6)
Top鹏 杜. said on
i run javah -d jni -classpath ...... comand , and it has generate head file.
then I add the ndk path to local.properties, and then run build-.make project, whye my project does not generate so file at ndk folder ?
my email:4909004@qq.com
鹏 杜. said on
I do not know why, I delete old project and build a new project then it run as well
Piyush G. said on
I have followed the same steps and I have all the required .c/.h files inside the jni folder. I have also updated the ndk path in local.properties.. but Android studio is still not attempting to build the .so file.
is there some configuration i need to change to ask it to start building C/C++ code inside jni folder ?
Matthew G. said on
This is a very useful video. However, I have not been able to figure out how to include the ndk libraries. Specifically, I can include <android/log.h> and the constants from that file are found, but the function definitions are not. I'm guessing I need to be configure gradle somehow, but I have not been able to find instructions anywhere. Do you know how to do this?
Matthew G. said on
My question was actually answered at 10:04. I should have watched till the end :/
rash b. said on
I am getting the following error on running the project and I feel that it is because my .so files are not getting generated. Why are my .so files not generated? My email is bindalprashast@gmail.com
02-17 15:54:43.499: E/AndroidRuntime(13387): Process: com.pcvlab.glasslocalization, PID: 13387
02-17 15:54:43.499: E/AndroidRuntime(13387): java.lang.UnsatisfiedLinkError: Couldn't load pcv_glass_localization from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.pcvlab.glasslocalization-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.pcvlab.glasslocalization-1, /vendor/lib, /system/lib]]]: findLibrary returned null
02-17 15:54:43.499: E/AndroidRuntime(13387): at java.lang.Runtime.loadLibrary(Runtime.java:358)
02-17 15:54:43.499: E/AndroidRuntime(13387): at java.lang.System.loadLibrary(System.java:526)
02-17 15:54:43.499: E/AndroidRuntime(13387): at com.pcvlab.glasslocalization.MainActivity$1.onManagerConnected(MainActivity.java:63)
02-17 15:54:43.499: E/AndroidRuntime(13387): at org.opencv.android.AsyncServiceHelper$1.onServiceConnected(AsyncServiceHelper.java:318)
02-17 15:54:43.499: E/AndroidRuntime(13387): at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1114)
02-17 15:54:43.499: E/AndroidRuntime(13387): at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1131)
02-17 15:54:43.499: E/AndroidRuntime(13387): at android.os.Handler.handleCallback(Handler.java:733)
02-17 15:54:43.499: E/AndroidRuntime(13387): at android.os.Handler.dispatchMessage(Handler.java:95)
02-17 15:54:43.499: E/AndroidRuntime(13387): at android.os.Looper.loop(Looper.java:146)
02-17 15:54:43.499: E/AndroidRuntime(13387): at android.app.ActivityThread.main(ActivityThread.java:5602)
02-17 15:54:43.499: E/AndroidRuntime(13387): at java.lang.reflect.Method.invokeNative(Native Method)
02-17 15:54:43.499: E/AndroidRuntime(13387): at java.lang.reflect.Method.invoke(Method.java:515)
02-17 15:54:43.499: E/AndroidRuntime(13387): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
02-17 15:54:43.499: E/AndroidRuntime(13387): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
02-17 15:54:43.499: E/AndroidRuntime(13387): at dalvik.system.NativeStart.main(Native Method)
02-17 15:54:45.181: I/Process(13387): Sending signal. PID: 13387 SIG: 9
Add a Comment
Top(For technical discussions visit our developer forums. For site or software product issues contact support.)
Please sign in to add a comment. Not a member? Join today