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++.

  • Failed to export android application (Eclipse)
  • How to add dividers and spaces between items in RecyclerView?
  • Android: build native GUI app with NDK?
  • Is it possible to scale drawableleft & drawableright in textview?
  • How to force a meta-data value to type string?
  • Eclipse - Errors running builder 'Android Package Builder'
  • 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?

    Related posts:

    Android Libraries in Android Studio
    Android WebView not refreshed after webview content has been modified by JavaScript
    android - change achartengine graph background color
    Black screen before Splash screen appear in android
    Android 2.3 wifi hotspot API
    Do I need to uses always the last targetSdkVersion?
  • HTML5 video - frame accurate seeking on Android devices?
  • Fastest way to query contacts with “mobile phone numbers” on Android
  • How to display AdMob ad at bottom of screen in Android app with Xamarin/Monogame?
  • Is there a way to generate the R.java file in Android Studio?
  • Page Curl Animation in android?
  • How to retrieve a list of available/installed fonts in android?
  • 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.