Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve "invalid resource directory name", resource "crunch"

Tags:

java

android

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?

like image 548
Waqleh Avatar asked Nov 02 '13 20:11

Waqleh


9 Answers

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.

like image 110
Waqleh Avatar answered Oct 04 '22 11:10

Waqleh


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.

like image 44
Simulant Avatar answered Oct 04 '22 12:10

Simulant


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 :)

like image 41
dull_boy Avatar answered Oct 04 '22 12:10

dull_boy


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

like image 22
Toni Gamez Avatar answered Oct 04 '22 13:10

Toni Gamez


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!

like image 40
bstar55 Avatar answered Oct 04 '22 13:10

bstar55


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

like image 44
Vijay Bhushan Avatar answered Oct 04 '22 11:10

Vijay Bhushan


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

like image 41
azmeuk Avatar answered Oct 04 '22 11:10

azmeuk


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.

like image 45
Maxim Kogan Avatar answered Oct 04 '22 13:10

Maxim Kogan


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

like image 23
user2513737 Avatar answered Oct 04 '22 13:10

user2513737