Java 无法压缩文件 - Android studio (app:mergeDebugResources)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41267005/
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
Failed to crunch file - Android studio (app:mergeDebugResources)
提问by Tobias Marschall
i am currentyl trying to implement Google ActivityRecognitionApi. However i get following errors:
我目前正在尝试实施 Google ActivityRecognitionApi。但是我收到以下错误:
Error:Failed to crunch file C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-cast-framework\10.0.1\res\drawable-xxhdpi-v4\quantum_ic_forward_30_grey600_36.png into C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject\app\build\intermediates\res\merged\debug\drawable-xxhdpi-v4\quantum_ic_forward_30_grey600_36.png
Error:Execution failed for task ':app:mergeDebugResources'. Error: Failed to crunch file C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-cast-framework\10.0.1\res\drawable-xxhdpi-v4\quantum_ic_forward_30_grey600_36.png into C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject\app\build\intermediates\res\merged\debug\drawable-xxhdpi-v4\quantum_ic_forward_30_grey600_36.png
错误:无法压缩文件 C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-cast -framework\10.0.1\res\drawable-xxhdpi-v4\quantum_ic_forward_30_grey600_36.png 到 C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject\app\build\intermediates\res\merged\调试\drawable-xxhdpi-v4\quantum_ic_forward_30_grey600_36.png
错误:任务“:app:mergeDebugResources”的执行失败。错误:无法压缩文件 C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-cast -framework\10.0.1\res\drawable-xxhdpi-v4\quantum_ic_forward_30_grey600_36.png 到 C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject\app\build\intermediates\res\merged\调试\drawable-xxhdpi-v4\quantum_ic_forward_30_grey600_36.png
I am very new to Android developement and really dont know what to do.
我对 Android 开发很陌生,真的不知道该怎么做。
I appreciate any comments.
我很欣赏任何评论。
Thanks in advance
提前致谢
EDIT: My mistake! Forgot to copy some files...
编辑:我的错误!忘记复制一些文件...
回答by Martin Sing
Had the same problem. Move your project into a higher directory (like C:).
有同样的问题。将您的项目移动到更高的目录(如 C:)。
回答by mavHarsha
Failed to crunch file means studio can't process the file. Its too long and it has reached the max file path line of the operating system.
压缩文件失败意味着工作室无法处理文件。它太长了,已经达到了操作系统的最大文件路径行。
-> Crude wayto solve it is move the project to some folder in "C:\".
->解决它的粗略方法是将项目移动到“C:\”中的某个文件夹。
-> Better wayis to change the build directory of the project in the build.gradle file (Project)
->更好的方法是在 build.gradle 文件(Project)中更改项目的构建目录
allprojects {
buildDir = "C:/tmp/${rootProject.name}/${project.name}"
.
.
}
回答by Prasad Nageshkar
The length of the path\file name (the count of all characters in the name)has crossed the maximum limit. This is happening because a combination of length of file name and the multiple nested folder levels.
路径\文件名的长度(名称中所有字符的数量)已超过最大限制。这是因为文件名长度和多个嵌套文件夹级别的组合。
回答by rajeesh
this is because your project path is too long. Please make this as short as possible. It will resolve this error.
这是因为您的项目路径太长。请尽可能简短。它将解决此错误。
Like
喜欢
C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject
C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject
to
到
C:\ActivityProject
C:\活动项目
回答by Sean C.
It's because the path length has exceeded the maximum value. You do not have to move your project elsewhere. Just open a shell in the root directory of your hard drive and make a junction to your project:
这是因为路径长度超过了最大值。您不必将项目移到别处。只需在硬盘驱动器的根目录中打开一个 shell 并连接到您的项目:
D:\a\very\long\path\to\your\project
D:\a\very\long\path\to\your\project
cd \
mklink /j project D:\a\very\long\path\to\your\project
cd project
You can now make the building process without a pain
cd \
mklink /j project D:\a\very\long\path\to\your\project
cd project
您现在可以轻松完成构建过程
回答by krishnamurthy
which means that the path is too long to reach that particular file. make sure that your project is placed under the parent directory(do not go greater than 4 levels ).
这意味着路径太长而无法到达该特定文件。确保您的项目位于父目录下(不要超过 4 个级别)。
example:
例子:
C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject
C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject
instead use :
而是使用:
C:/your project directory/your project file
C:/你的项目目录/你的项目文件
the best practice is keep the project as easily available to the compiler.
最佳做法是使项目易于编译器使用。
回答by jajhonrod
In my case with Windows 7 (have to work with that :-|), moving to a higher directory in whatever the drive is located, or reduce the directory name length did the trick.
在我使用 Windows 7 的情况下(必须使用 :-|),无论驱动器所在的位置移动到更高的目录,还是减少目录名称长度都可以解决问题。
回答by Ankit Shukla
I am using android studio with react-native. I faced the same error regarding 'failed to crunch file'. I just updated my project's gradle from 2.3 to
我正在使用带有 react-native 的 android studio。我遇到了关于“无法压缩文件”的同样错误。我刚刚将我的项目的 gradle 从 2.3 更新到
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
and all started working again.
一切又重新开始工作。
回答by Abhilash Reddy
This is happening because file name and path is too long
这是因为文件名和路径太长
1) rename the folder to a shorter name
1)将文件夹重命名为较短的名称
2) move the project to the folder to a simple path like
2)将项目移动到文件夹到一个简单的路径,如
c:/android projects/Project Sample
c:/android 项目/项目示例