Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

I had a similar error on a Linux machine. It turns out that aapt uses the 32bit emulation libraries, and if they fail for some reason then the build process can fail mysteriously at this location in build.xml.

In my case the reason for the failure was CircleCI had to patch their kernel to blacklist a newly found vulnerability in a 32bit emulation API. They were then able to patch their kernel to eliminate the vulnerability within a couple of days.

On OSX I just cleaned the project and rebuilt and that worked for me.

Project > Clean (pick your project name)

If you are running ant from command line use command 'ant clean release' instead of just 'ant release'. If you are using eclipse disable autobuild delete crunch folder and then execute ant more info : http://pissedoff-techie.blogspot.in/2014/07/android-build-fails-with-ant-on-eclipse.html

I tried the solutions here such as: restarting eclipse, clean the project and rebuild, removing crunch folder and run ant again etc. After running ant script (from eclipse) it seems that ADT interferes and generates crunch folder repeatedly. The workaround for me was just to run ant from command line. Initially i had to execute the following steps to remove the crunch folder:

  1. Disable Build Automatically option from Project menu.
  2. Manually remove the cruch folder.
  3. Run ant clean release from command line.

Hi try this line and build it again.

rm -fR $(find . -type d -name crunch|xargs)

I also had same kind of issue. I manually deleted 'bin' and 'gen' folders of the library and tried. It worked for me.

Add this line into top of the custom_rules.xml

<delete dir="../YourLibraryName/bin/res/crunch"/>

if do not have custom_rules.xml, create one and put this into the file. Place the custom_rules.xml within your project dir.

<?xml version="1.0" encoding="UTF-8"?>

<project name="imported" >

<delete dir="../YourLibraryName/bin/res/crunch"/>

</project>

UPDATE

It can be done by adding following line in library project build.xml.

   <delete dir="${out.absolute.dir}"/res/crunch />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top