I've followed the steps given in the Android Developer Blog to generate a build.xml for building releases for an Android Application. I need to do a custom compiling so I have overwritten the target compile of the ant_rules_r3.xml as it is said in the generated build.xml.
<target name="compile" depends="-resource-src, -aidl, -pre-compile" ...
The script works fine and generates the apk, but the problem is that Eclipse shows an error because it cannot find targets -resource-src
, -aidl
and -pre-compile
(which are loaded when executing the script but are not really present on the build.xml). As there are these errors I cannot work with the project in Eclipse.
How can I skip the validation of this single file in Eclipse?
Kukudas's solution to "Ignore all buildfile problems" does solve the root problem.
However, Eclipse will still detect the buidl.xml as broken and will not allow Ant Builders to call the file. In fact, Eclipse will silently ignore such build steps in your project as if weren't there.
I do not know if you can do this for a single file but i think you can disable the validation within the eclipse preferences under Validation.
I found 2 solutions that work for me :
1 - The solution from kukudas above :
While it works, this solution is workspace specific and can be quite tedious if a user wants to keep Ant validation for a few files but ignore a large number of files.
2 - Eclipse seems to validate ant files only when they are opened in an editor. Therefore, another solution involves never opening ant files that shouldn't be validated using eclipse. I managed to get rid of warnings by doing a file backup-delete-restore.
Ideally, ant validation should be done like all other XML validation so it may be configured at project level.
I have figured out a much better solution to the problem of eclipse not finding build targets from the imported/included projects. First of all, upgrade to the r14 sdk. Revision 14 uses only a build.xml file from the ${sdk.dir}/tools/ant directory
At the bottom of the build.xml file within your own project, you'll see an import statement that looks like this:
Change this statement to
Then from your project, you can reference those target with
Also note that now they have pre-compile/pre-build tasks that will be called before compiling. (checkout the full build.xml to see exactly when they are called). You can use these as hooks to do some work before compiling without overriding the original tasks.
Another workaround (less drastic than disable all validation/problem reporting): Go to Window->preferences->Ant->Problems tab. Add "build.xml" to the ignore list...