Oct
9

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

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

NestedVM

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. 

 

JIGAR PATEL

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 JigAr Patel

More PostsWebsiteTwitterFacebook

You may like to read this also....

4 Comments to “how can I write applications in C or C++ for Android?”

  • ruunyytikkil October 4, 2012 at 7:37 am

    Thanks for the nice blog. It was very useful for me. Keep sharing such ideas in the future as well.

  • Martin March 14, 2013 at 10:12 am

    Hi there. Really a great post. Very interesting post for me. Thanks for sharing it.

  • karthick March 19, 2013 at 4:54 pm

    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……

  • karthick March 19, 2013 at 5:21 pm

    my email id is [email protected]

Post comment

*

CommentLuv badge
Follow us on Twitter! Follow us on Twitter!

Search in this website

our sponsors

latest comments

Find us on Facebook

Top Authors

35 posts
saurabh
22 posts
10 posts

Find us on stackoverflow

Polls

Tell us who you are

View Results

Loading ... Loading ...

My Bookmarks

Sponsers Link