2

enter image description hereError:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

We have already added android.enableAapt2=false in gradle.properties file

InsaneCat
  • 2,115
  • 5
  • 21
  • 40
Ramkailash
  • 1,852
  • 1
  • 23
  • 19
  • Please refer this it's helps you:- https://stackoverflow.com/questions/46988102/errorcom-android-tools-aapt2-aapt2exception-aapt2-error-check-logs-for-detail/46988596#46988596 – InsaneCat Dec 06 '17 at 10:52
  • What error are you getting after adding android.enableAapt2=false in your project – Android Geek Dec 08 '17 at 05:01
  • Check this answer https://stackoverflow.com/a/50216453/3806413 – 0xAliHn May 07 '18 at 14:19

6 Answers6

4

For me, there was no need to add android.enableAapt2=false to my gradle.properties. The solution for me was to make sure that in my gradle build file my compileSdkVersion is set to 26, buildToolsVersion is set to 26.0.2 and targetSdkVersion is set to 26.

Note: In my build file, I had to do this check for all target and compile sdkVersions including product flavors:

  • mobile
  • tv

I am using Android Studio 3.0.1.

chornge
  • 2,021
  • 3
  • 28
  • 37
3

For anyone who is still having issues, i.e loading up demos etc or importing projects. You need to make sure (like everyone else has stated):

You add the following statement to your gradle.properties file

android.enableAapt2=false

Now here is for the bit that they should have filled you in on. Chances are if you have imported a project there may not be a gradle.properties file this can be for a wide range of reasons old gradles being used auto fixing issues on build etc.

But seriously, If you can't find it right click in gradle scripts and click on new resource bundle and type gradle. This will create a gradle.properties just paste that code there and run the program. I would not use this as a permanent work around. I stumbled across this whilst importing a project that didn't have a gradle attached to the folder, normally making an app from scratch will have the properties file there.

Ghost.Idle
  • 69
  • 8
  • Read my comment it's about adding the gradle properties file, which no one has mentioned. – Ghost.Idle Mar 11 '18 at 00:39
  • That means you are answering a wrong question. The OP is not asking how to find the `gradle.properties` or how to create a `gradle.properties` in case if it is not found anywhere. – Enzokie Mar 11 '18 at 00:48
  • quite a toxic little fella aint yah – Ghost.Idle Mar 11 '18 at 11:06
  • Which part is toxic? Please don't interpret my previous comment badly, I am just actually trying to help. – Enzokie Mar 11 '18 at 11:09
2

Solved it mate finally

please update your compileSdkVersion to 26.That will solve your issue.I think so

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

i have Solved it with increasing compileSDKVersion to 26

Ghimire
  • 948
  • 1
  • 9
  • 28
1

In my case it was caused by this line being missing from the Gradle dependencies:

implementation 'com.android.support.constraint:constraint-layout:1.1.0'

Jon
  • 7,941
  • 9
  • 53
  • 105
1

For Cordova developers those working on android studio
I had faced this issue while changing the support library from com.android.support:appcompat-v7:23.0.0 to com.android.support:appcompat-v7:27.1.1 in order to support the foreground service feature of Android Oreo; to solve this add the following lines of code in build.gradle file `

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
    minSdkVersion 26
    targetSdkVersion 27
      }
} 

After that comment following lines of code in build.gradle file. **Most important

cdvCompileSdkVersion cdvCompileSdkVersion
buildToolsVersion cdvBuildToolsVersion

Rebuild the project.

KH_AJU
  • 109
  • 2
  • 18
0

Add to your gradle.properties file this line

android.enableAapt2=false

EDIT:

You should use stable verison of Android Studio 3

mac229
  • 4,319
  • 5
  • 18
  • 24