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:
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?
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.
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.
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.
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.
The answer is here:
http://pissedoff-techie.blogspot.in/2014/07/android-build-fails-with-ant-on-eclipse.html
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With