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
49
votes
5 answers

How to configure NDK with Android Gradle plugin 0.7

The new Android gradle plugin (0.7) seems to include new support for the NDK, but in the documentation there is little to no mention of it (the only reference I found is a test called ndkSanAngeles). It looks like gradle is looking for the NDK,…
user1906
  • 2,310
  • 2
  • 20
  • 37
48
votes
4 answers

Android architecture usage?

I have a few native libraries that are fairly big and bloating the application binary size. I looked into APK splitting but maintaining and QAing multiple APKs is not something I want to do. So I'd like to exclude unused architectures in my release…
kos
  • 1,770
  • 2
  • 19
  • 41
48
votes
6 answers

Android ndk std::to_string support

I'm using android NDK r9d and toolchain 4.8 but I'm not able to use std::to_string function, compiler throws this error: error: 'to_string' is not a member of 'std' Is this function not supported on android ndk? I try APP_CPPFLAGS := -std=c++11…
albciff
  • 18,112
  • 4
  • 64
  • 89
46
votes
5 answers

How to compile C into an executable binary file and run it in Android from Android Shell?

I have a Device on which I installed Android Gingerbread 2.3.4 Here i want to run C executable file on android device I am able to run android NDK application on this Device and it runs perfect. But I want to run only one hello.c executable file on…
user1089679
  • 2,328
  • 8
  • 41
  • 51
46
votes
5 answers

Is "std::cout" usable in Android-ndk

In Android-ndk, we could use "__android_log_write", "__android_log_print", ... etc to output messages to the "LogCat" window. How about if I use "std::cout" to output some strings ? E.g. std::cout << "some strings" << std::endl; Where would the…
user1129812
  • 2,859
  • 8
  • 32
  • 45
46
votes
6 answers

Integrate MuPDF Reader in an app

I am working on some stuff that should be able to read PDF in my app and I want to put PDF view in my custom layout. I had preferred Android PDF Viewer but when I performed zoomIn, zoomOut it takes too much time. So currently I am supposed to use…
dharmendra
  • 7,835
  • 5
  • 38
  • 71
46
votes
2 answers

Unknown host CPU architecture: arm64 , Android NDK SiliconM1 Apple MacBook Pro

I've got a project that is working fine in windows os but when I switched my laptop and opened an existing project in MacBook Pro M1. I'm unable to run an existing android project in MacBook pro M1. first I was getting Execution failed for task…
Atif AbbAsi
  • 5,633
  • 7
  • 26
  • 47
46
votes
12 answers

More than one file was found with OS independent path 'lib/x86/libusb.so'

I am using libusb in my android application. When I am trying to build libusb native library then I get below error message, *.so files generated. Error:Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'. More than one…
N Sharma
  • 33,489
  • 95
  • 256
  • 444
46
votes
2 answers

Error in final launch sequence Failed to execute MI command -gdb-set target-async off

I have two projects on eclipse, one produces an so and the other is Android application which uses it I am trying to debug the native code in the so using this guide. I set my application debuggable I started my application in the debug mode I…
Yamen Ajjour
  • 1,422
  • 13
  • 32
45
votes
5 answers

How to access resource with dynamic name in my case?

If I get the image name as a variable like following: var imageName = SERVICE.getImg(); Then, how can I get the resource with R.drawable.????, I tried R.drawable[imageName], but it failed. Any suggestions?
Leem
  • 17,220
  • 36
  • 109
  • 159
45
votes
22 answers

OpenGL ES 2.0 Extensions on Android Devices

As this page for OpenGL ES 1.x, I collect OpenGL ES 2.x Extensions for Android Devices on this page. The listing can be found with my benchmark tool gpubench. This information can help many game developpers. Thanks for your help,
Ellis
  • 1,521
  • 1
  • 14
  • 16
45
votes
5 answers

Installing & using the Android NDK in Eclipse

I've been running the Android SDK for a while now in Eclipse (MAC OSX). I've downloaded the NDK and installed the C/C++ tools in Eclipse, but could anyone guide me on using the NDK? For example, do I just create an Android project like normal and…
ingh.am
  • 25,981
  • 43
  • 130
  • 177
44
votes
3 answers

What library does ld option -lrt refer to (Bionic libc)?

What does this option to ld mean? -lrt I know to some degree it means that ld is looking for the library with real-time extensions, but after searching extensively, I couldn't find an exact definition (or which library) this is referring to. With…
dwerner
  • 6,462
  • 4
  • 30
  • 44
44
votes
2 answers

How To Get File In Assets From Android NDK

I'm trying to access an image file in the assets folder from the native side. Now I can successfully search through the assets folder and its subdirectories locating the particular file that I am looking for: AAssetDir* assetDir =…
Dyn0myte
  • 650
  • 1
  • 5
  • 11
43
votes
3 answers

Android NDK debugging in Eclipse - how to stop segfaults/SIGILL that only occur when stepping in native code

I have set up debugging in Eclipse for native code using the Android NDK (on Windows XP, with Cygwin) to the stage where I can set breakpoints in both Java and native code and the debugger will break at them correctly. My issue is that when stepping…
epochengine
  • 2,072
  • 17
  • 21