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
40
votes
6 answers

Redirect stdout to logcat in Android NDK

I can't get my Nexus S (running Android 4.0) to redirect native stdout message to logcat. I've read that I need to do this: $ adb shell stop $ adb shell setprop log.redirect-stdio true $ adb shell start However, this doesn't seem to work. (It does…
Sebastian Krysmanski
  • 8,114
  • 10
  • 49
  • 91
39
votes
6 answers

Cross compiling static C hello world for Android using arm-linux-gnueabi-gcc

I want to build a static hello world from C using arm-linux-gnueabi-gcc as opposed to using the NDK standalone toolchain or Codesourcery for that matter. In Ubuntu... I have done the following: sudo apt-get install gcc-arm-linux-gnueabi I created a…
corbin
  • 1,446
  • 2
  • 27
  • 40
39
votes
2 answers

unused DT entry: type 0x1d arg

I am using android NDK-r10d to build Android x86 executable (shared linking) that runs on adb shell. On run time, I am getting the following warning: WARNING: linker: ./myapp: **unused DT entry:** type 0x1d arg 0x4a604 I am using a rooted Nexus…
39
votes
5 answers

Want to compile native Android binary I can run in terminal on the phone

I've been trying for a couple days to compile a native ARM Android binary that will execute on my phone using a terminal application. I want to generate the same type of binary as the standard Posix binaries installed on the phone like ls, mkdir…
Synthetix
  • 2,035
  • 3
  • 24
  • 30
39
votes
1 answer

How to get ndk-gdb working on Android?

I'm trying to get the NDK debugger working but with no success so far. To make sure my debug symbols are present and valid, I use the compiler options -O0 and -g, and the ndk-build parameter NDK_DEBUG=1. The ndk-gdb script runs with out issues and…
Simplex
  • 930
  • 1
  • 9
  • 20
38
votes
1 answer

Getting warning "NDK is missing a 'platforms" directory.' with no NDK

I've got a project that only uses the Android SDK, not the NDK, but I'm getting warnings whenever I build with gradle about the NDK: NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. …
CorayThan
  • 17,174
  • 28
  • 113
  • 161
38
votes
4 answers

Android studio Where to install NDK file? (downloaded it in zip)

My android studio said it wanted to update. But when I did I tried to update it but it wouldn't work so I had to launch: C:\Users\username\AppData\Local\Android\sdk\tools\android.bat to install other packages. But the NDK file wouldn't update, so I…
Tim
  • 547
  • 1
  • 7
  • 17
38
votes
10 answers

Android NDK Default location

I am used to previous versions of NDK builds which came in zip format. I downloaded the recent r10 version for windows which had a .exe version. The exe version is just an extractor, that I didn't know and double clicked it. It didn't ask me for the…
0xC0DED00D
  • 19,522
  • 20
  • 117
  • 184
38
votes
8 answers

Eclipse compiles successfully but still gives semantic errors

NOTE: it apparently is a recurrent question on StackOverflow, but - for what I have seen - either people never find a way or their solution does not work for me The problem: I am using Eclipse Juno ADT. Everything was working fine until I tried to…
JonasVautherin
  • 7,297
  • 6
  • 49
  • 95
37
votes
12 answers

How to make Android apps which support both 32-bit and 64-bit architecture?

I've just received and read a newsletter from Google Play mentioning that from next year on, the store "will require that new apps and app updates with native libraries provide 64-bit versions in addition to their 32-bit versions". For those who…
JorgeAmVF
  • 1,660
  • 3
  • 21
  • 32
36
votes
5 answers

Android ndk-build iostream: No such file or directory

I'm having a problem with compiling a .cpp file using the ndk-build tool (Windows 7 with Cygwin). The error appears when I try to compile the .cpp file with #include: jni/native.cpp:5:20: error: iostream: No such file or directory Here is my .cpp…
Andrey Zavarin
  • 1,483
  • 2
  • 13
  • 12
36
votes
4 answers

How to compile and run a C/C++ program on the Android system

Q1) I want to run a simple c program on android emulator.I am using windows xp os on my machine. I have installed sdk, jdk, eclipse for android development and succeeded running android application on AVD. Q2) I just need to know is there any way to…
user1125898
  • 361
  • 1
  • 3
  • 3
36
votes
3 answers

Android - tutorials for OpenGL ES 2.0 using the NDK?

I'm looking to learn OpenGL ES 2.0 on Android and the tutorials I've found are nearly all for using the SDK with Java. I want to use native code however so I want to do it through the NDK. The only tutorial/example I've found is the sample-stuff in…
KaiserJohaan
  • 9,028
  • 20
  • 112
  • 199
36
votes
5 answers

Android: sound API (deterministic, low latency)

I'm reviewing all kinds of Android sound API and I'd like to know which one I should use. My goal is to get low latency audio or, at least, deterministic behavior regarding delay of playback. We've had a lot of problems and it seems that Android…
Pavel P
  • 15,789
  • 11
  • 79
  • 128
36
votes
2 answers

Android NDK: How to get compiler architecture in Android.mk dynamically

I'm trying to configure Android.mk to cross compile native code to support different chipset namely armeabi, mips, and x86. I know I can configure Application.mk in the following way to compile the source code for different chip set: APP_ABI :=…
LuxuryMaster
  • 577
  • 1
  • 4
  • 11