7

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?

M A
  • 71,713
  • 13
  • 134
  • 174
Javi
  • 19,387
  • 30
  • 102
  • 135

5 Answers5

9

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.

kukudas
  • 4,834
  • 5
  • 44
  • 65
  • It doesn't solve the problem. I've suspended all the validators under the Validation section and cleaned the project but the errors are still there. Maybe this errors are not coming from a validator. Eclipse calls this error "Ant BuildFile Problem". – Javi Oct 15 '10 at 10:24
  • 8
    How about this: under preferences ant -> editor in the tab Problems "Ignore all buildfile problems" ? You can set there a specific file too if i'm not mistaken. – kukudas Oct 15 '10 at 10:28
  • ant -> editor -> 'ignore all buildfile problems' worked for me as well. Thanks!! – fatfreddyscat Aug 28 '12 at 02:24
7

Another workaround (less drastic than disable all validation/problem reporting): Go to Window->preferences->Ant->Problems tab. Add "build.xml" to the ignore list...

Pepster
  • 1,996
  • 1
  • 24
  • 41
1

I found 2 solutions that work for me :

1 - The solution from kukudas above :

How about this: under preferences ant -> editor in the tab Problems "Ignore all buildfile problems" ? You can set there a specific file too if i'm not mistaken. – kukudas Oct 15 '10 at 10:28

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.

Steve McDuff
  • 338
  • 2
  • 11
1

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.

Anm
  • 3,291
  • 2
  • 29
  • 40
  • This ant script is just to build the project outside eclipse. I want that eclipse ignores it, it's just an alternative to Eclipse apk generation. – Javi Oct 18 '10 at 11:00
  • It's a problem on my project, where I'm using an Ant task (in both build systems) to populate some constants and resources during some pre-compile targets. – Anm Oct 18 '10 at 20:48
0

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:

<import file="${sdk.dir}/tools/ant/build.xml"/>

Change this statement to

<import file="${sdk.dir}/tools/ant/build.xml" as="androidbuild" />

Then from your project, you can reference those target with

<target name="compile" depends="androidbuild.-resource-src, androidbuild.-aidl, androidbuild.-pre-compile" />

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.

Matt Wolfe
  • 8,924
  • 8
  • 60
  • 77
  • Unfortunately this did not work for me. Would have been a clean solution. – Steve Aug 08 '12 at 19:05
  • it does work, I've been using this method for a year or so now without problems. – Matt Wolfe Aug 09 '12 at 08:10
  • actually, its possible that the parent build targets are hidden and can't be referenced. If you use non hidden targtes (starting with a dash, then it definitely does work). I will have to test this specifically as I'm only referencing the release and clean targets of the parent build file. – Matt Wolfe Aug 09 '12 at 08:26