Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
1  
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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.