2012-10-25

Eclipse Juno problem building Android NDK

When building code from the Android NDK Beginners Guide, simply trying to get a tutorial on OpenSL to run, I ran into some freaky and troublesome bugs with Eclipse.

Code from Chapters 1-5 built without a hitch.  Starting with Chap. 6,  I started having strange intermittent problems. I could import a project, build it and run it, but then I'd do a double take when errors started popping up all over the place, without having made any changes.

I was getting "Field could not be resolved" and "Function could not be resolved" under the Problems tab whenever I tried to build the project.  If I build from the command line, I can get the project to "Run as Android Project" even right inside Eclipse, however, as soon as I open a file for editing, little red error X's start popping up all over everything.  I spent hours and hours trying to check paths and properties, and project configuration, and even my .bashrc and .profile files.  ANYTHING to hunt down and fix this.

Finally, I went to Project/Properties/C-C++ General/Code Analysis and un-checked a couple boxes:
Field could not be resolved
Function could not be resolved


NOT an ideal solution, because now I won't get nice error highlighting for miss-spelled function names etc... BUT now it works inside Eclipse.  This can be set on either a Workspace or Project level, by the way.

Apparently the issue is with the Indexer.  The Eclipse Juno Indexer has a bug where in some situations it will give erroneous validation.  This, in turn, log-jams the build/run process, stopping it in it's tracks based on imaginary errors.  Another way to get around it is to simply right-click on the errors in the "Problems" Tab at the bottom of Eclipse, and delete them.

I'll be doing some updates to see if this bug has already been addressed, I hope so.

2012-10-18

Android NDK R7 major issue glDrawTexfOES

Howdy peoples.  Been a minute since I last posted.

In the process of learning the Android NDK, I've run into a potentially immensely frustrating issue, especially for anyone just trying to learn.  This problem had me stumped literally for days.  Until I brought it to my brother's attention and he found this post:

https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/Inip9SFiRZs

I was attempting to build and run, in Eclipse, some tutorial code from the Android NDK Beginners Guide.  Chapters 6 and 7 to be exact.  I started receiving errors like this:


Function 'glDrawTexfOES' could not be resolved

All of the errors were acting as if the libraries simply were not there, but they were there and the make files appeared to all be in order.

Apparently, the issue mentioned in the Google groups post above, extends to the usage of ANY extension libraries post R6.

Currently, my code is building and running after I changed the Android.mk file to include this line:

LOCAL_CFLAGS    := -DRAPIDXML_NO_EXCEPTIONS -DGL_GLEXT_PROTOTYPES

instead of:
LOCAL_CFLAGS    := -DRAPIDXML_NO_EXCEPTIONS

I may come back and post more about this later, because I may want to add more specifics about the errors I received before the fix.

I want to make one thing clear.  Although Eclipse certainly was not helpful in pinpointing the route of this problem, this is not and Eclipse issue, but an Android NDK issue.

UPDATE:
2012/11/06  -- I thought I might as well post this, because it goes right along with the above problem.  I created a short set of instructions for things that need to be done every time I import the tutorial code from the Android NDK Beginner's Guide.  I really don't have time to explain all the reasons why, but I made this list for myself, so I wouldn't forget, and here it is for the public:


Select File/Import
Select the project folder and check the box for copy project to workspace

Open Android.mk, under jni folder, and change this line:

LOCAL_CFLAGS    := -DRAPIDXML_NO_EXCEPTIONS

to this line:

LOCAL_CFLAGS    := -DRAPIDXML_NO_EXCEPTIONS -DGL_GLEXT_PROTOTYPES

Right click on the project and select Android Tools/Fix Project Properties

Then go to project/properties/C/C++ General/code analysis and uncheck:

Field could not be resolved
Function could not be resolved

Or errors will start popping up as soon as you open anything in the editor.  It might run the first time, but as soon as you try to look at it, it will activate the indexer and start throwing up errors.  Apparently the indexer is not designed to recognize NDK code, of some kinds, in an Android development context.  Oh, Eclipse you rascally rabbit you....