0

I'm a student trying to use Android Studio and as shown below, I'm having errors when I try to build why is this happening? Also, how can I fix it?

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: 
com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs 
for 
details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or -- 
debug 
option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
9 actionable tasks: 1 executed, 8 up-to-date

P.S: I'm not sure what the thing that says in the try section means.

Shashanth
  • 4,995
  • 7
  • 41
  • 51
J.Kwon
  • 21
  • 2
  • Change you project path, Below is the problem most probably. caused by the path length restriction. I think it's 256 characters maximum. Relocate your project and the build will succeed. – Keyur Thumar Sep 03 '18 at 03:19
  • We need to see what the error is (check logs!). Can you either show us your build log or if you can't find it go to Terminal window in Studio and run "gradlew :app:mergeDebugResources" and edit the question post with the output? I'll help you figure out how to fix the error. – Izabela Orlowska Sep 04 '18 at 14:43

1 Answers1

0

Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

see this link, Aapt2 is enabled by default to speed up builds.
Update your gradle version and this error should disappear, alternatively disable aapt2, but prefer to upgrade the gradle version, as just disabeling aapt2 hides the problem, and also slowes down your build.

updating
build.gradle(top level)

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4
    }
}

gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

alternatively disable it in gradle.properties

android.enableAapt2=false
Stefan
  • 100
  • 2
  • 10