\_\_ANDROID\_\_ macro suddenly not defined


I’m working on an app which uses NDK (all I’m writing happened both on r6b and r8d)

Everything was working fine, and I wanted to start and try debugging my C code.

I followed this http://tools.android.com/recent/usingthendkplugin tutorial, but NDK_DEBUG 1 tag to my build command, suddenly I started getting errors in the code which didn’t go away even after removing that tag, changing from Android 4.2.2 back to 2.2, changing the NDK I was using, or anything else I could think of.

The problems happens now inside statements like this

#ifdef __ANDROID__
some cool android code
some pretty awesome iOS code

what happens it that the __ANDROID__ is for some reason not define, causing eclipse and ndk-build to try and compile the iOS code instead of the Android’s

Reverting everything I did didn’t seems to have any effect. Restarting eclipse didn’t as well. Cleaning the project, completely delete libs and obj directories didn’t work too..

Any suggestions?



Maybe it’s worth adding that the build itself, using ndk-build completes successfully. I think it might be an eclipse issue, but even if so, it still an error and I can’t launch the app

Also, just in case, restarting the computer didn’t work either.

EDIT 2: The problem exists on another computer running the same workspace over network, my guess was something related to the workspace, so I tried deleting .metadata folder and adding the project again.

Deleting the .metedata folder fixed it the 1st time, but after a few minutes (in which I managed to build and run the app on my tablet) the same issue returned, and deleting the .metadata didn’t work


Still no go.

However, I can confirm that it’s not a project specific problem, as all the projects that has Native support in eclipse now do this.

Other things that doesn’t work:

  • creating an empty project, adding Native support.
  • Completely changing to another unrelated workspace and perform the above tests
  • Downloading fresh version of eclipse (juno), CDT & ADT (was using the eclipse ADT bundle)


If anyone else encounters this issue:

I opened the workspace on another computer (Workspace is in a Dropbox folder), and the problem was still there on the other computer, which could only mean a workspace issue, so I delete the .metadata folder from the workspace.

I had to re-add the projects, but after doing so, everything seems to work now.

Answered By – La bla bla

Leave a Comment