Using Native code (C,C++) in Android applications using NDK

Md Zakir Hossen · 163K views · 2015 · 25:34

Open on YouTube

C, C++, Rust, Go & systems languagesTesting, debugging & developer toolstutorialdated

Why Stack Overflow recommends it

Stack Overflow users cite it as the tutorial they followed when first setting up NDK and JNI, usually while asking why their native setup fails.

Recommended by 0 people across 0 different months, 2015 to 2017.

What it is

A 25-minute screen-recorded tutorial from 2015 on calling native C and C++ code from Android apps with the NDK and JNI. It walks through writing a C file, the Android.mk build files, running ndk-build and loading the resulting library from Java. The presenter is a developer who made it after struggling to use the Stasm library.

What people said

Cites Urma Tilekov · 2015-11 · Stack Overflow · on “Native method not found:”

Help me please. This is my first code in NDK. I make all how showed in this video Using Native code (C,C++) [this video] but I get Native method not found: C file name is "ndktest.c" #include <jni.h> #include <string.h> extern "C" jstring Java_com_checksound_visualisator_MainActivity_helloWorld(JNIEnv* env, jobject obj) { return (*env)->NewStringUTF(env, "Hello Urma"); } My java class is package com.checksound.visualisator; public class MainActivity extends AppCompatActivity... public native String helloWorld(); static { System.loadLibrary("ndktest"); }

Cites cdahms · 2016-07 · Stack Overflow · on “Android Studio, OpenCV, C++, jni, NDK - unable to configure?”

I'm attempting to get OpenCV C++ calls to work within Android Studio using jni & the Android Studio NDK. These are the references I've been working from: [LINK] [LINK] [LINK] [LINK] [LINK] [this video] [LINK] Android NDK: how to let gcc to use additional include directories [LINK] For the most part I've been attempting to get the 2nd OpenCV sample (first of the links above) to run within Android Studio. This is the closest I have gotten so far: [LINK] Currently I'm getting the error: C:\Users\Chris.Dahms\Documents\AndroidOpenCVCppProgs\OpenCVTestNative\app\src\main\jni\jni_part.cpp Error:(2, 28) opencv2/core.hpp: No such file or directory I've tried everything in the above links to no avail. I sh

Cites Michael Kemp · 2017-03 · Stack Overflow · on “Do I have to copy libraries to jniLibs every time I update them (Android)?”

I learned about JNI files through this tutorial: [this video] After lots of experimentation I have figured out that in order to link a C file to Android it seems that I need to Create an application.c file in a "jni" directory outside my src directory Create Android.mk and Application.mk files, also in he "jni" directory Run "ndk-build" in a terminal to create lib___.so files in a "libs" directory Copy these lib___.so files to a "jniLibs" folder under src/main In my activity, load the library I created in the c file Include an unimplemented native method that I call whenever I want to get my data My problem is that whenever I want to change anything in my C application I need to repeat steps 3 an