Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NDK API reference docs? [closed]

I'm looking for reference documentation for the NDK libraries, anyone know where to find them? not java APIs. I can't find any in the NDK directory or online.

like image 682
snk_kid Avatar asked Jan 09 '11 10:01

snk_kid


People also ask

Is NDK necessary for Android studio?

Using Android Studio 2.2 and higher, you can use the NDK to compile C and C++ code into a native library and package it into your APK using Gradle, the IDE's integrated build system. Your Java code can then call functions in your native library through the Java Native Interface (JNI) framework.

Which is better NDK or SDK?

It is important to mention that some Android Apps use NDK to achieve a specific functionality. That makes NDK and SDK somehow complementary in some cases. However, Android still recommends to only used NDK if you really need to.

What is NDK API level?

The Android NDK is a toolset that lets you embed components that make use of native code in your Android applications. Android applications run in the Dalvik virtual machine. The NDK allows you to implement parts of your applications using native-code languages such as C and C++.

What is difference between Android NDK and SDK?

Android provides Native Development Kit (NDK) to support native development in C/C++, besides the Android Software Development Kit (Android SDK) which supports Java. [TODO] more.


2 Answers

Yes the API documentation of the NDK is very sparse. Most of the docmentation is in the docs folder of the NDK itself. Also the examples are helpful.

Try to read through the "standard" JNI documentation. (http://java.sun.com/docs/books/jni/) The Android NDK is basically just JNI. But the Android ndk does not need the special header magic if you name your function accordingly.

for example:

a java class:

 package com.example.foo;

 class Bar {
     native void jnistuff();
 }

where you call jnistuff the NDK will look for the method:

void Java_com_example_foo_Bar_jnistuff(JNIEnv* env, jobject *self)
{
  [...]
}

and automatically call it. Do not forget "extern C" if you use C++

like image 50
plaisthos Avatar answered Oct 05 '22 10:10

plaisthos


The best documentation for NDK libraries is the folder with corresponding headers $NDK/platforms/android-n/arch-arm/usr/include. Do not overlook it.

As others have noted, $NDK/docs and http://developer.android.com/sdk/ndk/overview.html are also essential.

like image 45
youri Avatar answered Oct 05 '22 10:10

youri