40

lately I am getting this error from eclipse: "invalid resource directory name", resource "crunch", type "Android AAPT Problem" what is this problem and how to solve it?

1
  • comment of dull_boy help me, so thank you!
    – LogoS
    Jun 12, 2014 at 3:00

13 Answers 13

52

Fix:

from the menu click Project->Clean...

a popup window will appear. select the check box for the project that is making this issue then click OK.

wait and see, that is it.

5
  • 4
    Does anybody else have the experience that, like, you are constantly having to rebuild or clean or manually build or whatever, when using ADT on Eclipse? Is the project I'm on just hopelessly screwed up, or is ADT/Eclipse hopelessly screwed up? Anyway, yeah, YET ANOTHER problem in Eclipse solved by a make clean...
    – user435779
    Dec 4, 2013 at 18:39
  • 2
    This does not work for me. Anything else that I can do?
    – Lunchbox
    Feb 6, 2014 at 9:54
  • 2
    @user435779 The Ant build process for Android is just hopelessly screwed up. Jul 9, 2014 at 20:55
  • 1
    Does not work. And deleting the crunch file (as suggested elsewhere); the file just reappears.
    – ajbraus
    Jul 10, 2014 at 21:13
  • 12
    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 : pissedoff-techie.blogspot.in/2014/07/… Jul 17, 2014 at 8:39
32

Ant and the ADT Plugin for Eclipse are packing the .apk file in a different build chain and temp generation folders. Crunch is created by the ADT. Best to do is to start every step with a clean if you switch between the tools. use ant clean if you used the ADT from eclipse before. Use Projects -> clean ... in Eclipse if you used ant before. Hope this solves your problem. Also restarting Eclipse could help.

2
  • 4
    I was trying to build with ant while the project was open in Eclipse. Quitting Eclipse fixed the problem.
    – jab
    Feb 5, 2014 at 16:02
  • using ant clean on my main project and its referenced library projects did the trick Apr 17, 2014 at 13:57
19

I had the same issue: invalid resource directory name: D:\work\merge\Client_2_24\Client\bin\res/crunch. I tried Project->Clean but didn't work. Then I directly deleted the directory crunch and it worked :)

1
  • I just deleted the whole bin directory. And it works. Thanks. Nov 21, 2014 at 1:06
7

This problem is resulting of and Android requirement that in res folder only can have drawable, drawable-xhdpi, and so on. crunch is not one of this.

It's commented here.

https://stackoverflow.com/a/7168818/2411379

2
  • Do you know why I might be getting the same "Error: Invalid resource directory name" with drawable-xxxxhdpi?
    – jensiepoo
    Oct 6, 2015 at 17:22
  • Thanks @Toni. This was the fix for me. I was trying to use 'res/assets' for my resources. I changed it to 'res/drawable' and it worked like a charm after cleaning and rebuilding.
    – szMuzzyA
    Oct 19, 2019 at 15:51
5

First of all, I find that this annoyance manifests itself when alternating between building my code in Eclipse and building it via ant on the command line.

The solutions that involve cleaning the project(s) are fine, however, my source tree takes more than 5 minutes to build given the fact that much of the code makes heavy use of templates. I try to avoid cleaning whenever possible to keep from having to do a complete rebuild. So here's my solution:

Add the following to build.xml:

<target name="-pre-build">
    <delete>
        <fileset dir="${basedir}" includes="**/crunch/**"/>
    </delete>
</target>

This delete task in ant will recursively remove all crunch directories beneath the directory where the build.xml file is located. This task will run whenever I do an ant debug/release on the command line, which means I'll never have to clean my project as a result of this crunch nonsense again!

4

I could solve this issue by doing "ant clean debug". The above suggestions of cleaning the project from Eclipse didn't work for me.

0
3

If you don't want to use eclipse and get this error message with ant release -Dsdk.dir=$SDK_ROOT, you can just run ant clean -Dsdk.dir=$SDK_ROOT

2

This happened to me when I incorrectly imported a project to eclipse using "New Project ->Android Project from Existing Code". It caused the crunch directory to turn up somewhere unexpected. Importing using "Import -> Exising Projects into Workspace" solved it.

1

create a file called ant.properties in the folder where your manifest file is. add aapt.ignore.assets=crunch:(whatever the default values are in your android sdk/tools/ant/build.xml file commented above the property )

when using cordova from the command line it uses ant when using eclipse it uses android package manager

package manager compresses the png files and puts them into crunch, crunch is an invalid folder name for ant, if eclipse is set to build automatically, everytime u delete crunch it will be built again by the android package manager. you can test this by right click project, propteries, builders, unchecking android package manager, deleting crunch folder, and it will never come back again, you will also never have compressed png files again.

deleting the folder without doing any of these things and with eclipse open is just rolling the dice, will eclipse auto generate the crunch before cordova gets to the package-resource stage

1
  • Yes, a thousand times yes. Just include the crunch directory in the default filter. Yes. Jul 18, 2017 at 16:56
0

when I updated android SDK build tools to version 18 and 19, I had the same issue.

My solution is:

  1. go to google service library project - properties - builders - uncheck all builders
  2. delete all the files under bin folder
  3. run ant task to clean this project.

I believe the problem was that eclipse would build automatically, and generate files that are conflicted with ant build.

0

First of all try to Clean your project. If it works then well and good otherwise move into the bin -> res -> there is one folder named Crunch. Just delete that folder directly and clean the project again.

It will solve the problem.

0

while my error is

Error:Execution failed for task ':app:mergeDebugResources'. /path/to/project/app/src/main/res/drawable-xxdpi: Error: Invalid resource directory name

notice "drawable-xxdpi" is not valid folder name, while "drawable-xxhdpi" is right.

-1

Some of yours folders' names might not be allowed by the Android standard: check the folders you made, and rename them.

1
  • Referencing the standard, maybe even offering examples of disallowed folder names is in order here.
    – J0e3gan
    Dec 19, 2014 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.