Running C++ Native Applications on Android, The Final Point

Posted on 22 November 2007 by Hatem Ben Yacoub

C++ programmingWith the launch of Android mobile platform, Google announced that developers can use Java as programming language to create applications for the platform and using Dalvik as the Java virtual machine. The choice of Java was itself a limitation for many developers, especially low level progammers used to deal directly with different mobile hardware issues…

It’s true that, for example, Symbian support programming in C++, but here is the full and real situation. There is a lot of application developed for Symbian, but you have to always compile your application for the different platforms separately. Applications for Symbian 3rd edition don’t run on 2nd, or 1st edition devices. Sometimes applications for S60 3rd edition are compatible with N73, but not with N80, while it should be the same operating system and there is no reason for an application to be hardware dependant.

Now back to Android, the fact is only Java language is supported doesn’t mean that you cannot develop applications in other languages. This have been proved by many developers, hackers and experts in application development for mobile. The guys at Elements Interactive B.V., the company behind Edgelib library, succeeded to run native C++ applications on the Android platform, even that at this time there is still many issues on display and sound … etc. This include the S-Tris2 game and a 3D animation demo of Edgelib.

Wouter ten Brink, Elements Interactive CTO, told us by email “As our company focuses on native (C++) development only, we will keep looking for solutions to bring native applications to Android.”. He added “Personally, I believe Google will eventually offer a way to run native code, but we’ll have to see what will happen on this area the coming months.”

Performance Vs Portability

It’s clear that Google, by making Dalvik the Java Virtual Machine for Android, is looking for maximum portability against performance. The MSM chipsets, currently supported by Android, include a Java hardware acceleration, which is supposed to provide high performance for Java applications running on Android Handsets. But it’s not everything.

The Google answer on running C/C++ applications on Android from the FAQs is : “No. Android applications are written using the Java programming language”. Very simple answer, but the problem here is for developers and companies having ready to use code and applications for other mobile platform and looking to get their code ported to Android at low cost.

Java-Not-In-Time and JIT

The performance issue in reality isn’t due to Java itself, but to the virtual machine running Java code on mobile devices. You can run Java very fastly on PCs today with JIT VMs, thing not available for mobile devices, which make Java applications and games very slow on mobile. So what about Dalvik ? Dan Morrill posted on the Android developers group that “a just-in-time compiler is definitely on the Dalvik roadmap”.

This should answer the performance question about Java, Android and Dalvik, even that we don’t know much at this time on the Dalvik VM.


Finally the choice of Java on Android is to make mobile application developement faster and easier for developers, and to make Android platform more stable. Probably many don’t agree on coding in Java for Android and looking for native support. This could solve some problems for native developers, but will open the door for a huge new problems and incompatibilities. If Google decided to make Android the best open mobile platform, it’s also their choice to keep this platform safe for a better future.

« | Home | »

9 Comments For This Post

  1. imran tanveer Says:

    i want to know that can i run my c++’s code in mobile.

  2. Fred Says:

    As far as I know.. the Andriod isn’t running an MSM chipset but an OMAP 3430 which features an ARM A-8 Cortex CPU capable of SIMD instructions, vector floating point, MMX like instructions and even has the PowerVR SBX video chip on there which allows for vertex/pixel shaders!

  3. Kookiat Suetrong Says:

    very good article with rich information.

    กู้เกียรติ ซื่อตรง

  4. jt Says:

    We have Frameworks that help us port BREW code to WIN32, Windows Mobile, Pocket PC, and iPhone. To add Android to the list, it must support deploying of c++ apps.

  5. Niklas Collin Says:

    Why not just have a compiler on the phone and include C++-compilation to native code as an automatic step in the installation process? Standardized and specified properly it would work. Then you have it both ways, native code and a single source. A tool for code obfuscation could be used to make sure the source code remains closed if necessary.

  6. huy Says:

    I’ve got a problem:
    I can start a native C application from command line on android.
    I create an Android app that has a button. When I press the button,
    I will call a native C function to start the native application.
    The problem is that, that process of android app died. The logcat message
    is like that “WIN DEATH” and the native C application cannot be started.

    Please give me some suggestion.

  7. huy Says:

    I used arm-none-linux-gnueabi-xxx to compile. And as I knew, Android based on linux kernel, so we can start application that linux can organize. But now the problem is that
    “when we start the native application (process) from Android, there’s “something” that make both the current Android application and the native application died”. I think, there must be an application on Android that supervises all of the processes that started from Android. Is it true?

  8. Tim Says:

    Niklas Collin: What you describe is what ‘Just in Time’ compilers do. And contrary to this article it is possible to have portable C++ using LLVM. This is a virtual machine with a JIT compiler similar to the JVM or Dalvik. The difference is that it supports many more languages. JVM at least is closely tied to Java and getting C++ to compile into java/dex bytecode is tricky at best.

    The real difficulty I can see with just putting LLVM on android is providing a language bindings to the android API. Not in terms of technical difficulty, but it’s probably a lot of work.

    This is really needed though I think. According to one paper I read Java’s garbage collector increases RAM requirements by five times if you don’t want ridiculous performance penalties. And Dalvik currently doesn’t even have a JIT compiler!

  9. Tony Hartley Says:

    MoSync the Native C/C++ development kit for Android is now available at, it’s open source, download it. Feedback is much appreciated.

2 Trackbacks For This Post

  1. Jeśli nie Java, to co? Czyli inne języki programowania na platofrmę Android : GPhone - Platforma Google Android, Open Social. API, Programowanie, Nowoczesne Telefony Komórkowe, Iphone Says:

    [...] Hatem Ben Yacoub z Open Handset Magazine poddał w wątpliwość takie próby. [...]

  2. Do Android dream of something more than Java? « Mantrid’s Weblog Says:

    [...] There is however a lot of doubt about these attempts. Even a discussion arose on Google Groups. One of main concerns is such native code has to be compiled for every device out there that is going to run Android to make it fully supported. And Android was created to eliminate the need to recompile stuff. Hatem Ben Yacoub of Open Handset Magazine has addressed the issue here. [...]

Leave a Reply

Advertise Here
Advertise Here