Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What's the best way to go about this? I've never coded using two languages before, let alone for an android phone

share|improve this question
What's your goal exactly? Do you want to implement performance critical parts in C++, or why do you want to write in both languages? – bummzack Aug 28 '11 at 9:25
yes, the most important areas. – blissfreak Aug 28 '11 at 9:57
up vote 3 down vote accepted

Using the Android NDK you can build a native library in C/C++ and by exporting the functions as native you can call your functions as if it was standard Java code once you've initialised the library. There's plenty of tutorials available on getting started with the NDK as well as samples provided by Google.

It's important to note that the NDK isn't necessary for a lot of purposes, see the FAQ:

When to Develop in Native Code

The NDK will not benefit most applications. As a developer, you need to balance its benefits against its drawbacks; notably, using native code does not result in an automatic performance increase, but always increases application complexity. In general, you should only use native code if it is essential to your application, not just because you prefer to program in C/C++.

Typical good candidates for the NDK are self-contained, CPU-intensive operations that don't allocate much memory, such as signal processing, physics simulation, and so on. Simply re-coding a method to run in C usually does not result in a large performance increase. When examining whether or not you should develop in native code, think about your requirements and see if the Android framework APIs provide the functionality that you need. The NDK can, however, can be an effective way to reuse a large corpus of existing C/C++ code.

As for developing on an Android device, I would suggest downloading the SDK (and NDK if your application requires), getting the emulator working, and having a go at the tutorials, reading the technical articles for best practices, and making sure you understand the application fundamentals.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.