Building NDK apps with Android studio
Why Stack Overflow recommends it
Stack Overflow users link it as a step-by-step walkthrough for getting JNI and NDK code building in Android Studio, and many then ask follow-up questions about the errors they hit while following it.
Recommended by 5 people across 5 different months, 2014 to 2017.
What it is
A 21-minute screencast from 2014 showing how to create a new NDK application in Android Studio and port existing ones. It uses the javah and ndk-build workflow with a HelloJNI example and also covers APK splits added in the Gradle 0.13 plugin.
What people said
Recommends G3M · 2014-10 · Stack Overflow · on “Using ndk to create and the load a library but having problems with the load”
Make sure libs folder exists and you have .so files present in them. If your .so files exist in the jni/libs folder then you need to inform the build system to look for the .so files there. Add the following to your build.gradle sourceSets.main { jniLibs.srcDir 'src/main/libs' } Do not use absolute path in your static loadlibrary method Check this video for how to create NDK apps with Android studio [this video]
Recommends G3M · 2014-12 · Stack Overflow · on “Android Studio ndk example build errors”
Check out this video for building simple NDK projects with Android studio [this video] Alternatively you can also download Intel Native Developer Experience tool that comes with the NDK plugin for Android Studio
Recommends galvanize · 2014-12 · Stack Overflow · on “NDK in Android Studio not working”
I am doing every single step from video: [this video] but no shared libraries are generated. Here is a version, where android-studio should generate shared libraries on his own. However when I create apropraite Makefiles and execute ndk-build, shared libraries are not generated as well. MainActivity.java: public native String HelloJNI(); static { System.loadLibrary("HelloJNI"); } Build->Make Project [*@* main]$ javah -d jni -classpath {sdk_dir}/platforms/android-14/android.jar:../../build/intermediates/classes/debug com.example.ndker.ndkapp.MainActivity Creating HelloJNI.c : #include "com_example_ndker_ndkapp_MainActivity.h" JNIEXPORT jstring JNICALL Java_com_example_ndker_ndkapp_MainActivity_Hel
Recommends G3M · 2015-02 · Stack Overflow · on “How to build single APK with Android NDK and Gradle”
Use the keyword "fat" after you have defined all architectures that you plan to include in your apk in the build.gradle file as highlighted in the code below . This will build a FAT binary. Watch this video for more details [this video] arm { versionCode Integer.parseInt("1" + defaultConfig.versionCode) ndk { abiFilter "armeabi" moduleName "Processing" stl "gnustl_static" cFlags "-I/opt/local/include/opencv -I/opt/local/include" ldLibs libsDir + "armeabi/libopencv_core.a" ldLibs libsDir + "armeabi/libopencv_ts.a" ldLibs libsDir + "armeabi/libopencv_contrib.a" ldLibs libsDir + "armeabi/libopencv_ml.a" ldLibs libsDir + "armeabi/libopencv_java.so" ldLibs "log" ldLibs "z", "jnigraphics" } fat // <- H
Recommends user1446988 · 2015-05 · Stack Overflow · on “Android Studio NDK return jint”
I have successfully followed this tutorial [this video] to learn about building NDK apps with Android Studio. That tutorial uses a public native String HelloJNI(); That string is set in the HelloJNI.c file #include "com_example_myapplication_MainActivity.h" /* Header for class com_example_myapplication_MainActivity */ /* * Class: com_example_myapplication_MainActivity * Method: HelloJNI * Signature: ()Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_com_example_myapplication_MainActivity_HelloJNI (JNIEnv *env, jobject obj) { (*env)->NewStringUTF(env, "Hello from jni"); } and loaded at runtime with static{ System.loadLibrary("HelloJNI"); } Now Im attempting to do the same thing but retrieve an
Recommends GPrathap · 2015-05 · Stack Overflow · on “How to set up NDK on Intellij”
Now you can use Android Studio which is powered by IntelliJ. But It still not natively supporting Android NDK. But you can make NDK application with the help of javah command which is coming from Java JDK. This video( [this video] ) will explain how to do, in a really simple way. This answer may not helpful for you. But someone will be benefited.
Recommends ZdaR · 2015-09 · Stack Overflow · on “Integrating Opencv libraries in Android Studio and experimental Gradle’s plugin without .mk files”
As integrating ndk along with opencv in android studio is a time consuming process, so all I can do is to provide the resources which I referred recently to create an opencv project in Android Studio using ndk. Android NDK and OpenCV Development With Android Studio [LINK] Building NDK apps with Android studio [this video]
Cites sudharsan chandrasekaran · 2015-10 · Stack Overflow · on “How to fix 'javah' error to create JNI folder when using NDK with Android Studio?”
I Create a WebCam based Android Application. I follow a [this video] video to create JNI to support my project. But i will show error on creating a JNI folder in parent directory. When i compile the code in compiler D:\SRINIVASAN\WebCam_Android\SudharsWebCam\app\src\main>javah -d jni -classpath D:\Android-New\platforms\android-19\android.jar;.. \ ..\build\intermediates\classes\debug com.example.sudharsanc.sudharswebcam.CameraPreview It shows error as javah is not recognized as an internal or external command, operable program or batch file. Some of questions which the same already in stackoverflow , but it will not help to get the solutions. Guide me. Thanks in Advance. .
Cites gmmo · 2015-11 · Stack Overflow · on “android studio 1.4.1 Error:(15, 0) Gradle DSL method not found: 'ndk()'”
i am following this tutorial online [this video] and when I tried to build I keep gettingt his: Error:(15, 0) Gradle DSL method not found: 'ndk()' Possible causes: The project 'NDKTest' may be using a version of Gradle that does not contain the method. Gradle settings The build file may be missing a Gradle plugin. Apply Gradle plugin I have tried this thread: Android Studio Gradle DSL method not found: 'android()' -- Error(17,0) [LINK] but it is pretty old now. here's my build.gradle file apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "com.guitarv. [LINK] " minSdkVersion 17 targetSdkVersion 23 versionCode 1 versionNa
Cites Anu · 2016-01 · Stack Overflow · on “compilation terminated error showing while building ndk”
I am new to android NDK. I am using android studio.I followd the steps in Building NDK apps with Android studio [this video] . I created the c file with a native method and works fine. But after adding make files and build using ndk-build ,I am getting the following error. E:\Projects\NDKProjects\MyNDKSample\app\src\main>E:\ndk\android-ndk-r10e\ndk-build.cmd [armeabi] Compile thumb : HelloJNI <= HelloJNI.c jni/HelloJNI.c:16:1: fatal error: opening dependency file ./obj/local/armeabi/objs/HelloJNI/HelloJNI.o.d: No such file or directory } ^ compilation terminated. make.exe: *** [obj/local/armeabi/objs/HelloJNI/HelloJNI.o] Error 1 This is my MytestCode class, JNIEXPORT jstring JNICALL Java_com_exam