Android Studio:如果项目是在驱动器 C 上创建的,则“任务 ':app:mergeDebugResources' 执行失败”:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23359572/
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
Android Studio: “Execution failed for task ':app:mergeDebugResources'” if project is created on drive C:
提问by Vipul Shah
I added Google Play services as a dependency in my current project. If I save the project on the C: drive, I get the following error while syncing up the project:
我在当前项目中添加了 Google Play 服务作为依赖项。如果我将项目保存在 C: 驱动器上,则在同步项目时出现以下错误:
Error: Execution failed for task ':app:mergeDebugResources'.
> Error: Failed to run command:
C:\Program Files (x86)\Android\android-studio\sdk\build-tools\android-4.4.2\aapt.exe s -i C:\Users\ashokp\Desktop\Studio\AndroidV2SDK_AndroidStudioFormat\Google Play
Services\SampleApplication\AndroidV2SDKSampleApp_GooglePlayServices\app\build\exploded-aar\com.google.android.gms\play-services.3.23\res\drawable-hdpi\common_signin_btn_text_focus_light.9.png -o
C:\Users\ashokp\Desktop\Studio\AndroidV2SDK_AndroidStudioFormat\Google Play
Services\SampleApplication\AndroidV2SDKSampleApp_GooglePlayServices\app\build\res\all\debug\drawable-hdpi\common_signin_btn_text_focus_light.9.png
Error Code:
42
This only happens if the project is saved on the C: drive. If I save it to some other drive, it works perfectly.
仅当项目保存在 C: 驱动器上时才会发生这种情况。如果我将它保存到其他驱动器,它可以完美运行。
Does anyone else face this issue? What causes this? How can I fix/circumvent this?
还有其他人面临这个问题吗?这是什么原因造成的?我该如何解决/规避这个问题?
回答by fvasquezc23
This is caused by the path length restriction. I think it's 256 characters maximum.
这是由路径长度限制引起的。我认为最多 256 个字符。
Relocate your project and the build will succeed.
重新定位您的项目,构建将成功。
回答by Kristo258
I had the same problem. Try to go to Build - Rebuild project. I didn't get that problem again and my app successfully started.
我有同样的问题。尝试去构建 - 重建项目。我没有再遇到那个问题,我的应用程序成功启动。
回答by DoubleCui
add this in module's build.gradle.
将此添加到模块的 build.gradle 中。
android{
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
}
回答by Ranjithkumar
In drawable assets there was an image format which was an unsupported image. When i removed the image every thing started working fine.
在可绘制资产中,有一种不受支持的图像格式。当我删除图像时,一切都开始正常工作。
回答by v.d
For developers who live in Iran, Just rebuild while offline. You're done! (it's related to sanctions!)
对于居住在伊朗的开发人员,只需离线重建即可。你完成了!(跟制裁有关!)
回答by JaneSnail
I have a similar problem with Error:Execution failed for task ':app:mergeDebugResources
. And at last I found the reason is the pictures resource error which use the incorrect ".9.png".
我有类似的问题Error:Execution failed for task ':app:mergeDebugResources
。最后我发现原因是使用不正确的“.9.png”的图片资源错误。
回答by mehulmpt
In my case, I created a folder audio
in res
directory. That caused the problem! Deleting the folder fixed it. Hope it might help someone.
就我而言,我audio
在res
目录中创建了一个文件夹。这导致了问题!删除文件夹修复了它。希望它可以帮助某人。
回答by L-N
I encountered the same error.
我遇到了同样的错误。
In the end, the problem was that I used an image in res/drawable that I copied in there and saved it as .png although the original file was .jpg .
最后,问题是我在 res/drawable 中使用了我在其中复制的图像并将其保存为 .png ,尽管原始文件是 .jpg 。
I deleted the file (there's a warning message if there are still usages for the item in your code, but you can ignore it) and pasted it in with the original .jpg ending.
我删除了该文件(如果您的代码中仍有该项目的用法,则会显示一条警告消息,但您可以忽略它)并将其粘贴到原始 .jpg 结尾处。
After a cleanup and gradle syncronization the error disappeared.
清理和 gradle 同步后,错误消失了。
回答by Reddy Raaz
Remove any capital letters or other not allowed symbols in resource file name.
删除资源文件名中的任何大写字母或其他不允许的符号。
Example: activity_parkingList --> activity_parking_list
示例:activity_parkingList --> activity_parking_list
回答by Milind Chaudhary
Update your gradle build tools in project level gradle , and it will show you the exact resource that is causing the error.
在项目级别 gradle 更新您的 gradle 构建工具,它将向您显示导致错误的确切资源。