Program for Android in C/C ++ with the Native Development Kit (if you dare)

Source: Internet
Author: User

Http://www.zdnet.com/blog/burnette/program-for-android-in-cc-with-the-native-development-kit-if-you-dare/1284

 

Not a big fan of Java? Well, get over it, because that's the primary and recommended way to write applications for Android devices. It's portable and... What's that? Android's Dalvik Java VM not fast enough for you? Granted, it's an interpreted engine and as of version 1.5 There's no just-in-time compiler. But Dan promises... Oh, can't wait for the JIT to come out? OK, OK, we'll let you program in C if you're really sure.

Introducing the android Native Development Kit (ndk ). with it, you can implement * parts * of your application using native-code versions ages such as C and C ++. you're familiar with the Java Native Interface (JNI), right? JNI lets you load a shared library and call C code from within java. The ndk lets you compile and build those libraries for the arm cpu chip used in all * Current * Android devices.

The ndk provides:

    • A set of tools and build files used to generate native code libraries from C and C ++ sources
    • A way to embed the corresponding native libraries into application packages files (.apk s) that can be deployed on Android devices
    • A set of native system headers and libraries that will be supported in all future releases of the Android platform, starting from Android 1.5
    • Documentation, samples, and tutorials

Users downloading your program from the market will not be able to tell whether or not you used native code. in fact, some apps already on the market use it. however, native code is not for everyone. google Engineer David Turner writes:

Keep in mind that using the ndk will not be relevant for all android applications. As a developer, you will need to balance its benefits against its drawbacks, which are numerous! Your application will be more complicated, have permission CED compatibility, have no access to framework APIs, and be harder to debug. that said, some applications that have self-contained, CPU-intensive operations that don't allocate much memory may still benefit from increased performance and the ability to reuse existing code. some examples are signal processing, intensive physics simulations, and some kinds of data processing.

You have been warned. Stay away from the ndk unless you really need it. Try optimizing your Java code first. Try profiling. Acupuncture, cold compresses, anything... What did do you say? "Shut ...," Hey, there's no need to be rude. Have at it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.