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

How do I post code to be run on the Android main thread from a separate thread in C++?

I have a separate thread running in C++ in the background and I want it to be able to post code to be run on another thread that's already running an android.os.Looper (e.g. the main thread). By 'post', I mean something akin to View#post where a…
Foxichu
  • 952
  • 10
  • 22
26
votes
8 answers

Enable Exception C++

I am trying to make APP native code for Android. The Native code is in cplusplus. Whenever I try to make, the following error appears. H236Plus.cpp:135: error: exception handling disabled, use -fexceptions to enable How do I use -fexceptions to…
Gidiyo
  • 411
  • 2
  • 7
  • 13
26
votes
5 answers

Android: error: cannot open crtbegin_dynamic.o: No such file or directory

I used the following... ~/Development/Android/android-ndk-r8c/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=/Users/me/toolchain Then I create the following code file... int main () { return 0; } I tried…
Jackie
  • 21,969
  • 32
  • 147
  • 289
26
votes
1 answer

Difference between armeabi and armeabi-v7a

As far as I can tell from the docs, the difference between the two supported flavors of ARM architecture in Android NDK is only in the set of supported CPU instructions. Is that really so? Is there no difference in calling conventions, or system…
Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
26
votes
5 answers

How to remove native support from an Android Project in eclipse because eclipse is showing errors in jni?

I accidentally clicked on "Add Native Support" inside "Android Tools"... That messed up all the jni files of my project. How do I undo that ? How to remove Native support from my Android Project ?
Amit
  • 13,134
  • 17
  • 77
  • 148
25
votes
2 answers

Using the STL with Android NDK C++

I am trying to use the STL in an Android NDK C++ File. I try to use map, vector and various other stl classes and I cannot compile it because it doesn't find the files. My classes header starts with: #pragma once #include #include…
HardCoder
  • 3,026
  • 6
  • 32
  • 52
25
votes
5 answers

Android NDK revision 7 Host 'awk' tool is outdated error

I am getting "Android NDK: Host 'awk' tool is outdated. Please define HOST_AWK to point to Gawk or Nawk !" error on latest android ndk revision 7.
MGK
  • 7,050
  • 6
  • 34
  • 41
25
votes
3 answers

How to tell Android NDK to use a different toolchain

I've downloaded a custom toolchain (linaro) to build ARM based Android apps. How do I tell the NDK to use it? Can I define or set something in Android.mk and Application.mk that would allow me to do that? Is there another way?
Phonon
  • 12,549
  • 13
  • 64
  • 114
25
votes
2 answers

How do I compile simple native code using Android.mk?

In particular I am trying to compile chainDD's su binary. I tried to use ndk-build but it seems I need to set NDK_PROJECT_PATH but what this should be set to is not described in the documentation.
user492922
  • 925
  • 2
  • 12
  • 23
25
votes
4 answers

How to copy values from one pointer to another

I have the following pointer: jfloat *verticesLocal; And I want make a new copy to: jfloat *vertices; I want to copy the values from verticesLocal to vertices. How can I do that? I've just tried the following command, but it doesn't…
VansFannel
  • 45,055
  • 107
  • 359
  • 626
25
votes
2 answers

How to disable android native debugger in Android studio

Using Studio 2.3, gradle:2.2.1 When I try to attached debugger to app, it shows Android Hybrid Debugger -> Now Launching Native Debug Session Attention! No symbol directories found - please check your native debug Start hybrid debugger. And…
Qamar
  • 4,959
  • 1
  • 30
  • 49
25
votes
12 answers

How to resolve the java.lang.UnsatisfiedLinkError in NDK in Android?

I am new in ndk development in android.I have gone through the file system of ndk android. Here, explaining what i have done. 1) i have created a folder named "jni" then create 2 file named Android.mk and ndkfoo.c. In Android.mk LOCAL_PATH := $(call…
Indrajit Kumar
  • 401
  • 1
  • 5
  • 13
25
votes
3 answers

NDK integration in Android studio

Today I updated my android studio to 1.3 and I enter the NDK (android-ndk-r10e NDK version) path in local.properties (ndk.dir=C:\AndroidNDK\android-ndk-r10e\android-ndk-r10e) but I got this error. Error:Execution failed for task…
user1517638
  • 972
  • 1
  • 10
  • 16
25
votes
0 answers

Android API 16 NDK cwctype and string build errors

Android NDK newbie question. I'm trying to compile a library using the Android NDK. I'm building for API16 and get the following errors in the build: In file included from…
25
votes
4 answers

Android Studio "Current NDK support is deprecated"

As of Jan 2015 the NDK support for Android studio is still unusable. A cryptic message says: "Alternative will be provided in the future." I'd like to know what's gradle/google direction on this is since it's impossible to plan a proper development…
Dado
  • 1,147
  • 1
  • 13
  • 31