Android Studio crash (aapt.exe returns 42) when I put a PNG file in a transfer folder

After yesterday's update, he will not create or run a project with these two PNG images as a background image. As soon as I delete these images everything works fine again (I put the images in a selectable folder).

:app:mergeDebugResources FAILED C:\Users\Daedlues\Desktop\Android-Studio-Projects\AndroidInterView\app\src\main\res\drawable\middle.png Error:Error: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Daedlues\Desktop\Work\SDK\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 42 Error:Execution failed for task ':app:mergeDebugResources'. > C:\Users\Daedlues\Desktop\Android-Studio-Projects\AndroidInterView\app\src\main\res\drawable\middle.png: Error: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Daedlues\Desktop\Work\SDK\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 42 Information:BUILD FAILED 
+6
source share
7 answers

This can also happen if you exceed the maximum Windows path length.

Android Studio - unable to open PNG file

+13
source

If "yesterday's update" refers to Android 5.1 (API 22), try using the latest build tools. Correct the build.gradle file to use buildToolsVersion "22.0.0"

+4
source

In my case, it turned out that the "png" image was really a "psd" image, which simply had the wrong extension. I had to convert it to "png" and then the error went away.

+2
source

This can happen when gradle fails to process resources.

In my case, it turned out to be an invalid image file in a folder with the ability to draw, so my XML layouts that Android Studio did not run ... for this solution, I prefer both ways

1> check extension and convert them .png to .jpeg

2> if it is useless, then remove from drawable

0
source

Check out the middle.png image. if it is a jpg or jpeg image, this is the reason.

0
source

I had the same problem and decided to do ./gradle clean build !

0
source

We received this error message. For some reason, our files were named foo.9.png - and the extra point worked. So, check if you have extra points in the file name.

0
source

Source: https://habr.com/ru/post/983728/


All Articles