Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant build fails inside Eclipse

For years, I've used the Ant integration for Eclipse to build my Android projects as outlined by Google on this documentation page. It's my favorite way of building release builds, because I can simply hit "Run external tool" in Eclipse to start the Ant build, and it runs in the background.

Since recently (I believe ADT 22.0 or 22.1), I've been getting the following failure:

[echo] Handling Resources...
[aapt] Generating resource IDs...
[aapt] invalid resource directory name: C:\path\to\project\bin\res/crunch

BUILD FAILED
C:\Android\android-sdk\tools\ant\build.xml:653: The following error occurred while executing this line:
C:\Android\android-sdk\tools\ant\build.xml:698: null returned: 1

I'm not sure what the cause of this is, since AAPT seems to generate the "crunch" directory itself. I've tried cleaning my project and disabling automatic building in Eclipse but to no avail.

I also tried executing ant release outside of Eclipse, but this gives the same error. Executing ant clean release doesn't work either, as it attempts to delete jars that are still in use by Eclipse. Therefore, the only solution that I've found to work at all is:

  1. Exit Eclipse
  2. Wait for the process to end
  3. Execute ant clean release

This is excruciating because as we know, restarting Eclipse is a royal pain. Furthermore, all affected projects need to be cleaned which makes the entire process take up to half an hour. I've opened issue #60496 on b.android.com, but haven't heard any official response.

Is there any solution to this aside from biting the bullet and switching to Android Studio?

like image 912
Paul Lammertsma Avatar asked Dec 12 '13 16:12

Paul Lammertsma


People also ask

How do I run Ant build in Eclipse?

Tip. You also can start an Ant build by highlighting the project in the Package Explorer and selecting Run→ External Tools→ Run As→ Ant Build. If you want to select the targets to run, you also can select Run→ External Tools→ External Tools→ Targets, select the targets you want to run, and click Run.

What does Ant build mean in Eclipse?

Ant is a Java-based build tool created as part of the Apache open-source project. You can think of it as a Java version of make. Ant scripts have a structure and are written in XML. Similar to make, Ant targets can depend on other targets. For example, Ant is used in the context of plug-in development in the build.

Does Eclipse support Ant?

Clicking on the targets, build / clean / usage will run Ant with the target. Clicking "fax" will execute the default target - usage. The Ant Eclipse plugin also comes with a good editor for editing build.

How do I debug an Ant script in Eclipse?

Open the Ant view (Window -> Show view -> Ant). If the build file isn't in the view then you can simply add it. Once added right click on the ant target you want to run and select Debug as -> Ant build. The Debug perspective should open up and the process should stop at your breakpoint where you can step through it.


2 Answers

The answer is here:

http://pissedoff-techie.blogspot.in/2014/07/android-build-fails-with-ant-on-eclipse.html

  1. Disable autobuild.
  2. delete crunch folder.
  3. run ant script.
  4. re enable auto build.
like image 81
Utsav Gupta Avatar answered Oct 19 '22 06:10

Utsav Gupta


Also from https://code.google.com/p/android/issues/detail?id=60496, I just deleted gen/* and bin/* in the project and it's referencing library. It worked.

like image 37
Agung Suyono Avatar answered Oct 19 '22 06:10

Agung Suyono