45

i am currentyl trying to implement Google ActivityRecognitionApi. However i get following errors:

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

I am very new to Android developement and really dont know what to do.

I appreciate any comments.

Thanks in advance

EDIT: My mistake! Forgot to copy some files...

Tobias Marschall
  • 2,355
  • 3
  • 22
  • 40

10 Answers10

89

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}"
    .
    .
}
mavHarsha
  • 1,056
  • 10
  • 16
33

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

rajeesh
  • 937
  • 10
  • 11
8

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.

4

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

iiro
  • 3,132
  • 1
  • 19
  • 22
Sean C.
  • 1,494
  • 1
  • 13
  • 22
2

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

Abhilash Reddy
  • 428
  • 1
  • 4
  • 19
1

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.

krishnamurthy
  • 1,574
  • 14
  • 14
0

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

Android Studio 2.2 Google play services sync Error

Community
  • 1
  • 1
Martin Sing
  • 1,247
  • 10
  • 15
0

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.

jajhonrod
  • 69
  • 3
0

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.

Ankit Shukla
  • 712
  • 8
  • 20
0

I am using Windows 10 Korean version. I could solve this issue moving my project folder to the path which includes only English letters. If there are someone who are using non-English version of Windows OS and having same issue this might be helpful.

D.Y Won
  • 245
  • 3
  • 5
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/30805451) – Melvin Jan 16 '22 at 03:02
  • Hi Melvin. Would you tell me why do you think my comment does not answer the question? I clearly stated in my comment that it might be helpful for those who uses non-English version of Windows OS. – D.Y Won Jan 24 '22 at 04:54