22

How can I solve this problem, when I am building it, it is showing me the same problem- java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details

I am using classpath 'com.android.tools.build:gradle:3.1.0'

What should be the exact solution. Please let me know as soon as possible.

Lokesh Kumar Gaurav
  • 726
  • 1
  • 8
  • 24
sumit coolbuddy
  • 221
  • 1
  • 2
  • 3

6 Answers6

17

There could be a problem in your res folders it could be an image that was not well converted so the solution to this is to update your gradle plugin which will highlight the actual problem

This line classpath 'com.android.tools.build:gradle:3.2.0-alpha18'

Edit your build.gradle file:

 buildscript {
    repositories {
        google() // important!
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-alpha18'
    }
}

allprojects {
    repositories {
        google() // important!
        jcenter()
    }
}

NOTE This might require to update your gradle to 4.6

Derrick
  • 179
  • 2
  • 8
  • Just upgrading to this gradle version saved my problem ! Amazing, this saved my day ! – Rémi P Aug 15 '18 at 16:45
  • @sumit coolbuddy You should mark this as the correct answer, this will help others to find the correct answer faster – Franz Sep 04 '18 at 16:30
  • Upgrading gradle helped it listed all the xml files that were corrupt, I faced the issue when I renamed a variable text, this refactored android:text to android:te – tanni tanna Dec 14 '18 at 15:33
  • I already had gradle updated to 4.6 but still build was failing with same error. Changing the Classpath to mentioned in answer created build successfully but can anyone explain this .. what happened by changing the classpath or a different version ? – Sajal Dec 17 '18 at 14:20
  • adding the class path above definitely solved the issue but I also had to pay attention to the pop up message at the bottom that said it needed to update afterwards. I clicked it and it updated it. – Lance Samaria Nov 09 '19 at 14:24
8

I had the same issue. Apparently this line had to be at the top of the main XML file and was 2 or 3 lines below.

<?xml version="1.0" encoding="utf-8"?>

Cut and pasted to top of XML file and build succeeded.

4
  1. Open your build.gradle(app module)
  2. Please make sure you have buildToolsVersion available in your gradle file (if it is missing please make sure you have to add (buildToolsVersion) same version as of compileSdkVersion)
  • Still not working ...com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details – Tarit Ray Apr 04 '19 at 15:08
4
error: invalid file path 'F:\AK-Android-Code\ak-im\build\intermediates\manifests\aapt\enterpriseArmV7\release\output.json'.
error: invalid file path 'F:\AK-Android-Code\ak-im\build\intermediates\manifests\aapt\enterpriseArmV7\release\AndroidManifest.xml'.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':ak-im:verifyEnterpriseArmV7ReleaseResources'.
> java.util.concurrent.ExecutionException: 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 11s
65 actionable tasks: 6 executed, 59 up-to-date

In my case,error info as above.I delete file folder F:\AK-Android-Code\ak-im\build\intermediates\manifests\aapt\ then rebuild project and it is successful. You can use ‘gradlew --debug assembleRelease ’ check gradlew's output info.

aolphn
  • 2,950
  • 2
  • 21
  • 30
2

Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details

Solve it in the following way in the Gradle:

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'+

this line

    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false
Yousha Aleayoub
  • 4,532
  • 4
  • 53
  • 64
Binyam
  • 21
  • 2
2

I have the same problem as you and solved this problem this way:

First, bulid a new "hello world" project in Android Studio and make sure it can correctly run. Then, open the build.gradle file to check the classpath. In my "hello world" project, the classpath is

classpath 'com.android.tools.build:gradle:3.5.1'

And then open the gradle-wrapper.properties file to check the distributionUrl.In my "hello world" project, the distributionUrl is

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

Finally, make the two configurations the same as "hello world" project in the imported project. The app could run correctly .

Dharman
  • 30,962
  • 25
  • 85
  • 135
cqLynnLee
  • 21
  • 1
  • This is what worked for me. Upgrading to 3.5.0 required gradle 5.4.1 instead of default 4.10.3 for cordova-android@8.1.0 – Silviu Burcea Apr 02 '21 at 12:15
  • I solved mine the same way. First step, close the current project and use the wizard to create a new, minimal project. I used `File -> New -> New Project -> No Activity`. After I fixed that (with a couple of SO searches), I was able to return to my main project. It still didn't run, but I had narrowed it down to the real problem, which was that the app was already install as a 'device owner'. – Stephen Hosking May 30 '21 at 06:29