I recently decided to look into C++ development for Android, specifically with the intention of exploring small-screen game construction.
I bought the book Beginning Android C++ Game Development by Bruce Sutherland and set about working along through the examples.
All went well until Chapter 4. The code I downloaded from the book’s website just wouldn’t get along with my IDE. It’s probably something weird with the way I set up Google’s ADT (Eclipse + Android) and NDK (Android C++) environment but I was having problems getting Eclipse to understand where to look for
Specifically, it refused to understand how to
Here’s how I got it to clean up its act and let me get on with learning about C++ development for Android…
Firstly in your project explorer view, right-click the project (Chapter5 in this case), then select Properties from the pop-up menu. From there, expand the C/C++ General topic and select Preprocessor Include Paths, Macros etc. and then the Providers tab.
I then found that nothing changed until I had re-indexed the project. To do that, right-click it again and then run down to Index > Rebuild;
I also found that the IDE didn’t remove the bug markers from the source tree until I re-opened the file in question;
After that the bug markers were gone and it all built correctly.
I’m still not sure why it got into this state. I’m definitely no Eclipse or ADT expert but this seems to have got me out of a hole I’d been unhappily stuck in for a while so hopefully it’ll help you too.
Edit: Apr 19 2014
Unfortunately the story doesn’t quite end there. I’m still having problems with some include paths somewhere. Specifically, it can’t find the
android_native_app_glue.h file which is in my
/usr/local/ndk/sources/android/native_app_glue/ folder. I’ll update when I’ve figured out how to set/check this properly.
I’ve also just updated the ADT bundle to Build: v22.6.2-1085508 and NDK to android-ndk-r9d, re-imported the Chapter4 project and I’m still seeing the problems described above. The same fix makes the
#import <list> work ok, but I’m struggling to fix
#include <jni.h> and
#include <android_native_app_glue.h> in
There’s a post on stackoverflow about using
#include <algorithm> to fix
std::find but that doesn’t work in this case either.
I’m getting annoyed now as I’ve found the C++ stuff easy going, all the hard work has been from fighting with the IDE.