How can I write applications in C or C++ for Android?

By -

Most of the people know that Development of Android Application is only done in java programming language. But Reality is that Development of Android application can be done in native languages like C & C++.

I have 3 option to do this all.

1> For doing this You need to use   Android NDK


The Android NDK is a companion tool to the Android SDK that lets you build performance-critical portions of your apps in native code. It provides headers and libraries that allow you to build activities, handle user input, use hardware sensors, access application resources, and more, when programming in C or C++. If you write native code, your applications are still packaged into an .apk file and they still run inside of a virtual machine on the device. The fundamental Android application model does not change.

Now To start Follow this step :

  1. Download & Install Google Android NDK. It contains libs, headers, makfile examples and gcc toolchain
  2. Build an executable from your C code for ARM, optimize and link it with provided libs if required
  3. Connect to a phone using provided adb interface and test your executable

If you are looking to buy an app:

  1. Build a library from your C code
  2. Create simple Java code which will use this library
  3. Embed this library into application package file
  4. Test your app
  5. Buy it or distribute it for free

2> Another option to Android NDK  is

MoSync SDK

MoSync makes it easy, fun and cost efficient to develop mobile application for all the major platforms. Using C++ and a set of powerful APIs, you can harness the full power of modern smartphone platforms while still supporting Java ME devices using a single codebase.

In short MoSync SDK is for cross platform mobile development.

Download its current release from here.

3> Once more option is do this is


Binary translation for Java

NestedVM provides binary translation for Java Bytecode. This is done by having GCC compile to a MIPS binary which is then translated to a Java class file. Hence any application written in C, C++, Fortran, or any other language supported by GCC can be run in 100% pure Java with no source changes.

Here you can use nestedvm to translate C  into Java bytecode, and use that as the basis of your port. For example, see the Android port of Simon Tathams portable puzzle collection.



Finally i want to share my personal thought about using native language in Android. Using native code does not result in an automatic performance increase, but always increases application complexity. 


Please also read.

Cross Compile C/C++ based programs and Run them on Android Smart-Phones

hey I am an Artist who love to write code...! Well I am an EC graduate From Ganpat University and now i am working as Embedded software engineer in one private firm.. find me at here Jeegar Patel

4 Comments to How can I write applications in C or C++ for Android?

  1. Really i didn’t get ur points admin…what is ADM and how to optimize the c code…my question is i had downloaded and installed android NDK…i successfully ran Hellow World app in emulator(code was in java) but,i tried simple c code to execute and instantly flashes the error binary code not found what is it mean? pls help me how to run c and c++ code in android eclipse…pls reply to email……

Leave a Reply

Your email address will not be published. Required fields are marked *