Questions tagged [android-ndk]

The Android Native Development Kit (NDK) is a companion tool to the Android SDK that lets build performance-critical portions of apps in native code or port existing libraries in C/C++ to Android. It provides headers and libraries that allows to build activities, handle user input, use hardware sensors, access application resources, and more, when programming in C/C++.

Android NDK applications that include Java code and resource files and and/or source code (and sometimes code). All native code is compiled into a dynamic linked library (.so file) and then called by Java in the main program using a mechanism:

Android NDK Application

The NDK is a powerful tool for developing Android applications because it:

  • Builds performance-critical portions of your applications in native code. When using Java code, the Java-based source code needs to be interpreted into machine language using a virtual machine. In contrast, the native code is compiled and optimized into binary directly before execution. With proper use of native code, you can build high performance code in your application, such as hardware video encoding and decoding, graphics processing, and arithmetical operation.
  • Reuses legacy native code. C/C++ codes can be compiled into a dynamic library that can be called by Java code with a JNI mechanism.

More information:

Latest Version: NDK Downloads

Version History: NDK Archives

Resources:

FAQ:

Books:

13539 questions
72
votes
5 answers

File Operations in Android NDK

I am using the Android NDK to make an application primarily in C for performance reasons, but it appears that file operations such as fopen do not work correctly in Android. Whenever I try to use these functions, the application crashes. How do I…
RyanCheu
  • 3,522
  • 5
  • 38
  • 47
71
votes
11 answers

How to copy and edit files in Android shell?

The Android shell does not have the cp command. Android shell also has no sed or grep or vi. I have no adb daemon available. There is mv command but it rejects to work if source is on a read-only device. What to do if I have to copy some…
psihodelia
  • 29,566
  • 35
  • 108
  • 157
70
votes
11 answers

aarch64-linux-android-strip file Missing

I updated to Android studio 2.3 and my project got these errors Error:org.gradle.process.internal.ExecException: A problem occurred starting process 'command…
Hanzala
  • 1,965
  • 1
  • 16
  • 43
70
votes
4 answers

Difference between CMake and NDK-build in android studio project

What is the actual difference between CMake and NDK build in android studio project. I already went through google documentation but the concept is not clear yet. As per google documentation: The Android Native Development Kit (NDK): a toolset that…
0xAliHn
  • 18,390
  • 23
  • 91
  • 111
70
votes
5 answers

Extract code from .aar file Android

How do I extract code from aar file.[Accidentally my main project is on another system can't access only have aar file on my mail] I need to extract the JNI code from aar file. I tried to change the extension to .jar but its extract .class only, Do…
Sophia
  • 1,046
  • 1
  • 12
  • 15
68
votes
11 answers

NDK can't find the application directory

When running the ndk-build command I get the following error: Android NDK: Could not find application project directory ! Android NDK: Please define the NDK_PROJECT_PATH variable to point to it. The contents of my Android.mk file: LOCAL_PATH :=…
Wessel van der Linden
  • 2,592
  • 2
  • 21
  • 42
67
votes
3 answers

Catching exceptions thrown from native code running on Android

The project I'm currently working on requires me to code up the android portion of a cross platform program implementation. A core set of functionality is built and included in my app through android-ndk. I've found that any exception/crash which…
Graeme
  • 25,714
  • 24
  • 124
  • 186
67
votes
3 answers

Whats NDK (side-by-side) in android sdk?

There's a ndk (side-by-side) at . Is it needed to install or just need to install the ndk?
Daniel Mana
  • 9,451
  • 13
  • 29
  • 41
65
votes
7 answers

Endianness of Android NDK

I'm working with my new app which processed captured image from cellphone camera. My phone is Nexus S, 2.3.4. I create a ARGB_8888 Bitmap with captured data. I know the ndk image lib, but it's only support 2.2 and above. So I pass the int[] of…
Matrix Bai
  • 1,097
  • 3
  • 11
  • 20
65
votes
3 answers

What is the Log API to call from an Android JNI program?

I would like to debug a JNI C application by inserting log messages to logcat. What is the C API that does this?
hopia
  • 4,880
  • 7
  • 32
  • 54
63
votes
3 answers

How to detect compilation by Android NDK in a C/C++ file?

Is there a preprocessor macro that will let me know NDK is compiling my code? I could manually define my own, but I'd rather not if possible.
Rémi
  • 3,705
  • 1
  • 28
  • 39
61
votes
2 answers

How to use 32-bit native libraries on 64-bit Android device

I use a native library in my application that is only compiled for armeabi, armeabi-v7a and x86. When this library is loaded on a 64-bit device like the Samsung S6, the application crashes with an UnsatisfiedLinkError java.lang.UnsatisfiedLinkError:…
Philipp E.
  • 3,296
  • 3
  • 34
  • 52
60
votes
3 answers

clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

I'm building a substratum theme from https://github.com/substratum/template I'm getting the following errors on run: Build command failed. Error while executing process /home/anubhav/Android/Sdk/ndk-bundle/ndk-build with arguments…
Anubhav Das
  • 940
  • 1
  • 11
  • 16
59
votes
6 answers

Embedded Chromium or Webkit in Android app

For our Android app, we would like to embed our own browser/rendering engine. The most likely candidate for this, is Webkit/Chromium. We are looking for something similar to WebView, essentially, but backed by a browser (version) that we…
Christian Klauser
  • 4,416
  • 3
  • 31
  • 42
58
votes
6 answers

How to create an object with JNI?

I need to implement some functions into an Android application using NDK and thus JNI. Here's the C code, with my concerns, that I wrote: #include #include jobject Java_com_example_ndktest_NDKTest_ImageRef(JNIEnv* env, jobject…
pmichna
  • 4,800
  • 13
  • 53
  • 90