Task :processDebugResources Failed to execute aapt com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.builder.core.AndroidBui
For me, I got this error while working on some Udacity projects. I fixed it by adding the following code to the top-level build.gradle file.
allprojects {
String osName = System.getProperty("os.name").toLowerCase()
if (osName.contains("windows")) {
buildDir = "C:/tmp/${rootProject.name}/${project.name}"
}
repositories {
jcenter()
google()
}
}
If you are seeking a way to get to the heart of the issue. Android studio contains a feature within the edit configurations panel that simplifies this possible. By clicking on the "app" tag (It is typically to the left of the top run button)
You will open the option to edit configurations. From there create an instance of the gradle option to yourself.
The core features are actually the gradle project as well as the task. Connect the task to your debug initiative.
When you run your app through this setting, Android will spit out detailed errors(That we all wish would appear more often) and these errros will point directly a what needs to be resolved.
Just in case above solution did not work. In my case , Bitdefender Antivirus was Preventing AAPT2 from making change on certain file.
You have a problem with a png file maybe, look here :
1 more Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:454)
It can be corrupted image or jpeg image with png extension
some symbols should be transferred like '%'
<string name="test" formatted="false">95%</string>
The error might be cause by non-ASCII symbols in gradle path. E.g. cyrillic symbols of the user folder. So, the problem is solved just by switching to another directory with ASCII-only path.