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
97
votes
2 answers

Calling a java method from c++ in Android

I'm trying to get a simple Java method call from C++ while Java calls native method. Here's the Java code: public class MainActivity extends Activity { private static String LIB_NAME = "name"; static { System.loadLibrary(LIB_NAME); …
Denys S.
  • 6,358
  • 12
  • 43
  • 65
97
votes
4 answers

How can I catch SIGSEGV (segmentation fault) and get a stack trace under JNI on Android?

I'm moving a project to the new Android Native Development Kit (i.e. JNI) and I'd like to catch SIGSEGV, should it occur (possibly also SIGILL, SIGABRT, SIGFPE) in order to present a nice crash reporting dialog, instead of (or before) what currently…
93
votes
7 answers

Any simple way to log in Android NDK code?

I'm looking for a way to easily debug C code in an Android NDK application using Eclipse. I've read ways to debug the app using gdb or something similar but what I want is a way to push messages to Eclipse somehow. I'm looking for a solution that's…
wajiw
  • 12,239
  • 17
  • 54
  • 73
90
votes
2 answers

android ndk gdb loaded sharedlibraries missing *.oat

Both gdb 7.7 and gbd 7.11 missed some shared libraries when debugging my device (oppo r7s). I've pulled all libraries to local. Here is a complete list of libraries shown by info shared (gdb) info shared From To Syms Read Shared…
Joey.Z
  • 4,492
  • 4
  • 38
  • 63
90
votes
4 answers

After updating Android Studio to version 1.3.0 I am getting "NDK integration is deprecated in the current plugin" Error

I have updated my Android Studio to version 1.3.0 before 3 days. Before that I can use NDK and now I am getting error like , Error:(50, 0) Error: NDK integration is deprecated in the current plugin. Consider trying the new experimental plugin. …
AndiGeeky
  • 11,266
  • 6
  • 50
  • 66
87
votes
8 answers

What is the Android Native Development Kit (NDK)?

What is the Android NDK (native development kit) ? How can one use it? Why should one use it?
Nikunj Patel
  • 21,853
  • 23
  • 89
  • 133
84
votes
9 answers

Can't include C++ headers like vector in Android NDK

When I try to include any C++ class like vector in my Android NDK project (using NDK r5b, the latest), I get an error like the following... Compile++ thumb : test-libstl <=…
Nitrex88
  • 2,158
  • 2
  • 21
  • 23
84
votes
2 answers

Android AudioRecord forcing another stream to MIC audio source

Update 3: I have partnered with another developer and we seem to found somebody who can do this for a large sum of money. They have sent us a test apk and it seems to work. We will go ahead and purchase the source. I hope we are not going to be…
nLL
  • 5,662
  • 11
  • 52
  • 87
81
votes
14 answers

Gradle sync failed, NDK not configured, download it with SDK manager

I am completely new to Android development and just installed Android Studio. I'm doing a very basic HelloGL2 exercise, and I opened up the HelloGL2.iml file. I tried running it, but it said that the gradle project sync failed and that the NDK is…
Karina H
  • 811
  • 1
  • 6
  • 3
81
votes
13 answers

[INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]

I have an issue with third party libraries that are imported to my project. I read quite a lot of articles about that but do not get any information how properly handle it. I put my classes .so to the folder. Problem is that the i try to run the…
Oleg Gordiichuk
  • 15,240
  • 7
  • 60
  • 100
80
votes
2 answers

How to use addr2line in Android

I am stuck with my app, as I am unable to debug as it is a multithreaded one and crashes with error SIGSEGV. I get lot of information from LogCat, which gives me addresses in my native library. It would be helpful if I could convert these addresses…
NoAIUser
  • 3,966
  • 6
  • 34
  • 52
78
votes
35 answers

NDK at ~/Library/Android/sdk/ndk-bundle did not have a source.properties file

I have updated Android Studio to 4.1 in Macbook but not able to run app after updating. It is giving following error Execution failed for task ':app:stripDebugDebugSymbols'. NDK at ~/Library/Android/sdk/ndk-bundle did not have a source.properties…
Krishna Meena
  • 5,693
  • 5
  • 32
  • 44
73
votes
3 answers

How to print a var using echo o print in a NDK-build Android.mk file to debug compilation?

I'm trying to print some extra info when in compile a library using ndk-build. For example: LOCAL_PATH := $(call my-dir) all:;echo $(LOCAL_PATH) echo: $(LOCAL_PATH) print:echo "i'm not working" When i do ndk-build, just compile all the Android.mk,…
vgonisanz
  • 11,831
  • 13
  • 78
  • 130
72
votes
2 answers

What is sharedUserId in Android, and how is it used?

I am confused in sharedUserID.what is use of sharedUserId?How to use?Where to use in android?
Bhargav Panchal
  • 1,159
  • 1
  • 12
  • 27
72
votes
4 answers

How to pass C structs back and forth to Java code in JNI?

I've got some C functions which I am calling through JNI which take a pointer to a structure, and some other functions which will allocate/free a pointer to the same type of structure so that it is a bit easier to deal with my wrapper. …
Nik Reiman
  • 39,067
  • 29
  • 104
  • 160