Why do so many Android apps use the NDK?

I’ve been looking through a few of the apps today (was actually looking to see how many use ACRA) but noticed that a lot of them use the NDK. I’ve been developing apps for quite some time and have yet to find a need for the NDK and as per the Android Developer site you shouldn’t really use it unless you need to:

In general, you should only use the NDK if it is essential to your app—never because you simply prefer to program in C/C++.

  • RelativeLayout align parent *side* + margin *side*
  • Shared preferences between two processes of the same application
  • Show progress spinner (refresh) on ActionBar?
  • What does PorterDuff.Mode mean in android graphics.What does it do?
  • How to set text to view from drawer header layout in navigation drawer without inflating view
  • Android - Blinking image using the Alpha fade animation
  • So this has got me to thinking… Am I missing something? I mean here are just a few of the apps using the NDK where I can’t really see a need for it:

    • WhatsApp
    • TuneIn Radio Pro
    • textPlus
    • Microsoft Tag
    • Star Chart
    • SPYMouse
    • SoundHound
    • Roll in the Hole
    • Facebook
    • Skype (Likely crypto libs)
    • Raging Thunder
    • QR Droid
    • PocketCloud
    • Camera Zoom FX
    • Blow Up
    • Paper Camera
    • Ocean HD Screen Saver
    • Office Suite
    • Instagram
    • Jump Desktop
    • Fieldrunners
    • Angry Birds apps

    I guess my thinking is perhaps they are using the same code on other platforms, libraries written in C and used on iOS, Android & other platforms, but I’m just not convinced that this is the reason. Are there any other things that these apps are likely to be using the NDK for? Other things I guess could be: Licensing, privacy/security (move complicated reverse engineering), Device IDs, Gaming engines etc.

    Anyhow, the question is really, do you have any ideas as to why so many apps are using the NDK?

  • Best method to download image from url in Android
  • Reading data from bluetooth device in android
  • Change ListView's textcolor
  • Enum vs. Static Constants, memory footprint
  • Android ProgressBar countdown
  • Project in Android Studio won't start - Activity Class Not Specified
  • 2 Solutions collect form web for “Why do so many Android apps use the NDK?”

    Not sure if this question is proper for StackOveflow, but as a developer using NDK I can give you two reasons from my perspective:

    • very large code base in C++, which is used also for versions on iPhones and Winrt, and also Windows CE/Desktop. It was developer for years, fixed, tested by lots of users.

    • its harder for hackers to learn what your code is doing, and to break it. But not impossible.

    I guess the first reason listed by marcin is the main reason.

    For my case, since there has been several C++ libraries used by IPhone and they do not want to port them to java impl, so just keep using it in Android.

    Because I am a Android developer, I totally disagree with this way. From the official doc, as you emphasized:

    In general, you should only use the NDK if it is essential 
    to your app—never because you     simply prefer to program in C/C++.
    

    But, just hard to push the whole solution to java… Painful in debugging, trouble shooting, anything is out of control.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.