Failed to crunch file - Android studio (app:mergeDebugResources)

放肆的年华 提交于 2019-11-28 06:11:52

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 way to solve it is move the project to some folder in "C:\".

-> Better way is to change the build directory of the project in the build.gradle file (Project)

allprojects {
    buildDir = "C:/tmp/${rootProject.name}/${project.name}"
    .
    .
}

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

to

C:\ActivityProject

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.

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:

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

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

example:

C:\Users\marschall\Desktop\googlesamples-android-play-location-2ed2964\ActivityProject

instead use :

C:/your project directory/your project file

the best practice is keep the project as easily available to the compiler.

Martin Sing

Had the same problem. Move your project into a higher directory (like C:).

Android Studio 2.2 Google play services sync Error

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.

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

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
} 

and all started working again.

This is happening because file name and path is too long

1) rename the folder to a shorter name

2) move the project to the folder to a simple path like

c:/android projects/Project Sample

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!