Java 如何解决“无效的资源目录名称”,资源“紧缩”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19746319/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to solve "invalid resource directory name", resource "crunch"
提问by Waqleh
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?
最近我从 Eclipse 中收到此错误:“无效的资源目录名称”,资源“紧缩”,键入“Android AAPT 问题”这是什么问题以及如何解决?
采纳答案by Waqleh
Fix:
使固定:
from the menu click Project->Clean...
从菜单中单击 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.
等等看,就是这样。
回答by Simulant
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.
Ant
和ADT
Eclipse插件正在收拾的.apk
不同构建链和临时文件夹中生成文件。Crunch
由ADT
. clean
如果您在工具之间切换,最好的做法是从每一步开始。使用ant clean
,如果你使用ADT
之前,从日食。Projects -> clean ...
如果您ant
以前使用过,请在 Eclipse 中使用。希望这能解决您的问题。重新启动 Eclipse 也有帮助。
回答by azmeuk
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
如果您不想使用 eclipse 并使用 收到此错误消息ant release -Dsdk.dir=$SDK_ROOT
,则可以运行ant clean -Dsdk.dir=$SDK_ROOT
回答by dull_boy
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 :)
我有同样的问题:无效的资源目录名称:D:\work\merge\Client_2_24\Client\bin\res/crunch。我试过 Project->Clean 但没有用。然后我直接删除了目录紧缩并且它起作用了:)
回答by Peter W.
when I updated android SDK build tools to version 18 and 19, I had the same issue.
当我将 android SDK 构建工具更新到版本 18 和 19 时,我遇到了同样的问题。
My solution is:
我的解决办法是:
- go to google service library project - properties - builders - uncheck all builders
- delete all the files under bin folder
- run ant task to clean this project.
- 转到谷歌服务库项目 - 属性 - 构建器 - 取消选中所有构建器
- 删除bin文件夹下的所有文件
- 运行 ant 任务来清理这个项目。
I believe the problem was that eclipse would build automatically, and generate files that are conflicted with ant build.
我认为问题在于 eclipse 会自动构建,并生成与 ant 构建冲突的文件。
回答by Vijay Bhushan
I could solve this issue by doing "ant clean debug". The above suggestions of cleaning the project from Eclipse didn't work for me.
我可以通过执行“ant clean debug”来解决这个问题。上述从 Eclipse 清理项目的建议对我不起作用。
回答by bstar55
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.
首先,我发现当在 Eclipse 中构建我的代码和通过ant
命令行构建它之间交替时,这种烦恼就会表现出来。
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:
涉及清理项目的解决方案很好,但是,鉴于大部分代码大量使用模板,我的源代码树需要超过 5 分钟来构建。我尽量避免清洁,以免不得不进行完整的重建。所以这是我的解决方案:
Add the following to build.xml:
将以下内容添加到 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!
此删除任务ant
将递归删除crunch
build.xml 文件所在目录下的所有目录。每当我ant debug/release
在命令行上执行操作时,此任务都会运行,这意味着我再也不必因为这种紧缩的废话而清理我的项目了!
回答by Maxim Kogan
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.
当我使用“New Project -> Android Project from Existing Code”错误地将项目导入到 Eclipse 时,这发生在我身上。它导致 crunch 目录出现在某个意想不到的地方。使用“导入 -> 现有项目到工作区”导入解决了它。
回答by Toni Gamez
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.
这个问题是由于Android要求res
文件夹中只能有 drawable
,drawable-xhdpi
等等。crunch
不是其中之一。
It's commented here.
这里评论了。
回答by Naresh Sharma
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 folderdirectly and clean the project again.
首先尝试清理您的项目。如果它运行良好,否则进入bin -> res -> 有一个名为 Crunch 的文件夹。只需直接删除该文件夹并再次清理项目。
It will solve the problem.
它将解决问题。