Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of Android NDK [closed]

Tags:

I'm new to the Android NDK. I want to know what is the benefit of native code in Android. How does it improve performance, and where is it (native code) used in Android?

like image 844
Andy Avatar asked Jun 18 '10 09:06

Andy


People also ask

What is Android NDK used for?

The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android, and provides platform libraries you can use to manage native activities and access physical device components, such as sensors and touch input.

How do I disable NDK?

go to Android Studio-> Tools -> SDK ManagerUnder SDK tools tab uncheck "NDK", "CMake", "LLDB" and then apply changes. NDK components will be removed.

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. NDK is a complex and advanced topics.


2 Answers

The NDK allows you to write code using C/C++ and then link it into your Java application. You can potentially increase the speed of your application. However, it may be worth reading about Replica Island, as they don't use the NDK, however achieve very fast frame rates.

The downsides to the NDK are, it only compiles to specific CPUs (whereas staying in Java land means it will work on any targetted version of Android).

like image 183
Mark Ingram Avatar answered Sep 23 '22 01:09

Mark Ingram


Droid, You can use native code, to optimize your application for speed. Especially when bit/byte operations are used in your code, like when you need to do compression / decompression of image files etc.

Native C code would use the underlying operating system's (linux) APIs (system calls), and hence would be much faster than when java code would have to be interpreted through the JVM.

Besides, allocation of large memory (to the tune of 25-30MB even!) can be done using native C code, using malloc(). This would not be possible when coding through java, in the confines of the application.

Most games use the native C code libraries for 2D / 3d graphics, input, sound etc...

If you are just beginning with the NDK, check out the following link for an easy tutorial with screenshots: http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/

like image 29
Roy Samuel Avatar answered Sep 25 '22 01:09

Roy Samuel