Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix com.android.builder.internal.aapt.AaptException: Failed to crunch file?

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

like image 558
user1884325 Avatar asked Sep 21 '16 15:09

user1884325


2 Answers

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!

like image 78
user1884325 Avatar answered Nov 04 '22 21:11

user1884325


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.

like image 9
user5980196 Avatar answered Nov 04 '22 19:11

user5980196