30
votes

I have the latest version of Android Studio (as of Sep 21, 2016). When I create a brand new project in Android Studio and try to build it, I am getting this build error:

Error: com.android.builder.internal.aapt.AaptException: Failed to crunch file H:..pathTo..\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\24.2.1\res\drawable-xhdpi-v4\abc_list_selector_disabled_holo_light.9.png

into

H:..pathTo..\app\build\intermediates\res\merged\debug\drawable-xhdpi-v4\abc_list_selector_disabled_holo_light.9.png

What does this mean? And how do I fix it?

Build log: https://jpst.it/NCnu

7
I got same problem, this is a better solution http://stackoverflow.com/a/34680168/5253418Blaken

7 Answers

75
votes

Amazing. It's 2016 and Google's tool chain still has these annoying file path limitations.

Error: File path too long on windows, keep below 240 characters

Move project further up your project file path and the problem goes away!

9
votes

There is a workaround. If you add the following to the project build.gradle file, inside the allprojects section, it will move the Build output files to this folder. Meaning the app will now build.:

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

It does give you an additional app module at the root of the project but this is a much more convenient option than moving whole Project folder path.

1
votes

I Found the same Error (Error: com.android.builder.internal.aapt.AaptException: Failed to crunch). I Copied the directory one level above. It Works!

1
votes

The solution that help me was to delete node_modules folder, remove android platform by running the command ionic platform remove android and then go upper the project folder in system hirarchy and then:

npm install
ionic platform add android
ionic run android
0
votes

I faced this problem when trying to generate an unsigned apk using Gradle in Android Studio IDE 3.0

I solved it by creating a fresh new project and copied each file with the slightest amendment needed e.g. changing the package name, but I left the icons as they are thus I haven't added a new icon in several files like I did in the previous project.

And the problem was solved, it builds with no such error. (However the generated apk file wasn't found in app\build\outputs\apk but inside app\build\outputs\apk\debug, but that's another problem which is not so important I hope).

0
votes

I encountered a similar error. Just try to reduce the path length by moving the project folder up. This will surely solve the problem.

0
votes

Update you gradle to latest one, it solve the problem, i was also facing same problem, it work for me.

I was using classpath 'com.android.tools.build:gradle:2.0.0', then replace to classpath 'com.android.tools.build:gradle:3.0.0' , it work for me.