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
35
votes
9 answers

Execution failed for task ':app:stripDebugDebugSymbols' in flutter

When I am trying to run my flutter app on a device my build fails to give this error Execution failed for task ':app:stripDebugDebugSymbols'. NDK at C:\Users\User\AppData\Local\Android\sdk\ndk-bundle did not have a source.properties file I have…
Archit Dandavate
  • 618
  • 2
  • 7
  • 20
35
votes
3 answers

How to unwind the stack to get backtrace for the specified stack pointer (SP)?

I'm writing this for Android (ARM only), but I believe the principle is the same for generic Linux as well. I'm trying to capture the stack trace from within the signal handler, so that I can log it when my app crashes. This is what I've come up…
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
35
votes
10 answers

How to install android ndk in linux?

I have downloaded android NDK from here: http://developer.android.com/tools/sdk/ndk/index.html for Linux 64-bit (x86) android-ndk-r10c-linux-x86_64.bin. How I do install it? The instructions don't work. My OS is 57-Ubuntu SMP Tue Jul 15 03:51:08…
Vardan95
  • 602
  • 1
  • 7
  • 15
35
votes
14 answers

How to find the Android version name programmatically?

I write code for finding the Android version like this String version=Build.VERSION.RELEASE; by using this code I am get the version number but I want version name. how to get the version name?
Venkat
  • 3,447
  • 6
  • 42
  • 61
34
votes
6 answers

Use C++ with Android ndk/jni

All the ndk samples only make use of basic C functions declared as extern in the header and defined in the cpp file. Then after including the header file in the C file containing the jni callback, everything works fine. Is it possible to use C++…
pot2mayo
  • 403
  • 1
  • 5
  • 9
34
votes
2 answers

How to avoid stripping for native code symbols for android app

I'm getting sigsegv 11 in native code and i need to avoid stripping to understand what's wrong. The app uses library (aar) and i was able to avoid stripping for the aar with 'cmd-strip' hack. But in the apk stripped version of .so is used anyway so…
4ntoine
  • 19,816
  • 21
  • 96
  • 220
34
votes
7 answers

How to set ANDROID_NDK_HOME so that Android Studio does not ask for ndk location?

My ndk is located at C:\Users\X\AppData\Local\Android\ndk. Now each time I create a new native android project and try to import into Android Studio, it asks me for the location of ndk. I can manually set the ndk in local.properties also. But I am…
Vinayak Garg
  • 6,518
  • 10
  • 53
  • 80
34
votes
2 answers

How to set variable according to gradle flavors

I want to pass a variable test that I set differently per flavor as a define to the NDK. But for some reason he always passes the value of the last flavor. Here is the build.gradle: apply plugin: 'com.android.library' def test android { …
Torge
  • 2,174
  • 1
  • 23
  • 33
34
votes
6 answers

How to display available branches in Android source tree?

Following directions on Android's main website to pull down sources, I'm looking at this command to initialize repo for the cupcake branch: repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake How can I view all available…
theactiveactor
  • 7,314
  • 15
  • 52
  • 60
34
votes
4 answers

run-as Package 'a.b.c' is unknown - Galaxy S4 Jellybean or Android 4.3

I cannot run run-as (or ndk-gdb) for the Galaxy S4 running Jellybean 4.2.2. ~ $ adb shell shell@android:/ $ run-as a.b.c ls run-as: Package 'a.b.c' is unknown There are multiple answers for this issue for pre-ICS devices, but those seem to have…
Paul Beusterien
  • 27,542
  • 6
  • 83
  • 139
34
votes
3 answers

How to simulate touch from background service with sendevent or other way?

Is it possible to simulate touch from the background application (or service) or to run sh script (that simulate touch)? It is needed for testing android system without USB or other connection to PC, thats why I can't (or don' know how) use Monkey…
v1k
  • 1,307
  • 2
  • 15
  • 20
33
votes
4 answers

How to make a symbolic link with Cygwin in Windows 7

Recently I have tested to write an Android application with native code in C/C++. The problem is in making symbolic links when using the Android NDK. After some googling, some say to use Cygwin. I have installed it now. How can I make a symbolic…
aemon
  • 789
  • 2
  • 7
  • 13
33
votes
4 answers

Android OpenAL?

Has anyone built OpenAL for the Android, or found the shared library for it on the system? This seems like an obvious need for a game of any kind, yet there's no resources out there for it. It seems the Android java sound library can't do pitch…
Kalen
  • 3,106
  • 8
  • 29
  • 42
33
votes
5 answers

Is there a need to check for NULL after allocating memory, when kernel uses overcommit memory

It is general practice to check for NULL (whether memory is successfully allocated) after a malloc(), some thing like void *ptr = malloc(10); if (ptr != NULL) { // do some thing usefull } else { // no memory. safely return/throw ... }…
FL4SOF
  • 4,161
  • 6
  • 28
  • 24
33
votes
2 answers

How to secure string in Android Application?

How to secure string in Android Application ? Options: ProGuard: It does not secure string? Does proguard work to obfuscate static string constants? Encrypt String: for Encryption I need to store encryption key (string) some where and again it's…
Ketan Parmar
  • 2,962
  • 19
  • 27