java – BuildException: Failed to execute aapt in Android Studio 3.1 Canary 6

I am facing this issue during gradle build:

    org.gradle.tooling.BuildException: Failed to execute aapt
    at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.invokeAaptForSplit(LinkApplicationAndroidResourcesTask.java:547)
    at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.doFullTaskAction(LinkApplicationAndroidResourcesTask.java:280)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.ide.common.process.ProcessException: Failed to execute aapt
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:794)
    at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.invokeAaptForSplit(LinkApplicationAndroidResourcesTask.java:525)
    ... 49 more
Caused by: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing process /home/local/MPROGA1/malwinder.singh/Desktop/SDK/android-sdk-linux/build-tools/27.0.1/aapt with arguments {package -f --no-crunch -I /home/local/MPROGA1/malwinder.singh/Desktop/SDK/android-sdk-linux/platforms/android-25/android.jar -M /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/res/merged/debug -m -J /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/generated/source/r/debug -F /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/res/debug/resources-debug.ap_ -D /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/multi-dex/debug/manifest_keep.txt --custom-package com.emerson.oversight -0 apk --output-text-symbols /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/symbols/debug --no-version-vectors}
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:792)
    ... 50 more
Caused by: com.android.ide.common.process.ProcessException: Error while executing process /home/local/MPROGA1/malwinder.singh/Desktop/SDK/android-sdk-linux/build-tools/27.0.1/aapt with arguments {package -f --no-crunch -I /home/local/MPROGA1/malwinder.singh/Desktop/SDK/android-sdk-linux/platforms/android-25/android.jar -M /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/res/merged/debug -m -J /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/generated/source/r/debug -F /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/res/debug/resources-debug.ap_ -D /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/multi-dex/debug/manifest_keep.txt --custom-package com.emerson.oversight -0 apk --output-text-symbols /home/local/MPROGA1/malwinder.singh/Desktop/Oversight/app/build/intermediates/symbols/debug --no-version-vectors}
    at com.android.build.gradle.internal.process.GradleProcessResult.buildProcessException(GradleProcessResult.java:73)
    at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:48)
    at com.android.builder.internal.aapt.AbstractProcessExecutionAapt$1.onSuccess(AbstractProcessExecutionAapt.java:78)
    at com.android.builder.internal.aapt.AbstractProcessExecutionAapt$1.onSuccess(AbstractProcessExecutionAapt.java:74)
    at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1237)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:911)
    at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:822)
    at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:664)
    at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:48)
    at com.android.build.gradle.internal.process.GradleProcessExecutor$1.run(GradleProcessExecutor.java:58)
Caused by: org.gradle.process.internal.ExecException: Process 'command '/home/local/MPROGA1/malwinder.singh/Desktop/SDK/android-sdk-linux/build-tools/27.0.1/aapt'' finished with non-zero exit value 1
    at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:382)
    at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:46)
    ... 9 more

Module level (inner) build.gradle:

        buildscript {
        repositories {
            maven { url 'https://maven.fabric.io/public' }
        }

        dependencies {
            //noinspection GradleDynamicVersion
            classpath 'io.fabric.tools:gradle:1.+'
        }
    }
    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply plugin: 'io.fabric'
    //For green dao
    apply plugin: 'org.greenrobot.greendao'

    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://jitpack.io" }
        jcenter()
    }

    android {
        compileSdkVersion 25
        buildToolsVersion '27.0.1'
        defaultConfig {
            applicationId "com.example"
            minSdkVersion 16
            targetSdkVersion 25
            versionCode 3
            versionName "1.1.1"
            multiDexEnabled true
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }

        lintOptions {
            checkReleaseBuilds false
            // Or, if you prefer, you can continue to check for errors in release builds,
            // but continue the build even when errors are found:
            abortOnError false
        }

        buildTypes {
            release {
                lintOptions {
                    disable 'MissingTranslation'
                }
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
            transitive = true
        }
        //AppCompat v7 support library
        compile 'com.android.support:appcompat-v7:25.3.1'
        //AppCompat v4 support library
        compile 'com.android.support:support-v4:25.3.1'
        //Support design
        compile 'com.android.support:design:25.3.1'
        //Google Maps
        compile 'com.google.android.gms:play-services-maps:11.8.0'
        //Retrofit - for making REST API calls
        compile 'com.squareup.retrofit2:converter-gson:2.1.0'
        //For Runtime permissions
        compile 'com.karumi:dexter:4.2.0'
        //To set custom fonts
        compile 'uk.co.chrisjenx:calligraphy:2.2.0'
        //Attaches bullets to viewpager
        compile 'com.robohorse.pagerbullet:pagerbullet:1.0.8'
        //Expandable recycler view
        compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
        //For Graph
        compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
        //Date time
        compile 'com.wdullaer:materialdatetimepicker:3.2.1'
        compile 'com.android.support:recyclerview-v7:25.3.1'
        testCompile 'junit:junit:4.12'
        androidTestCompile 'com.android.support:support-annotations:25.3.1'
        androidTestCompile 'com.android.support.test:runner:1.0.1'
        androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
        compile 'com.android.support:gridlayout-v7:25.3.1'
        compile 'com.jakewharton:butterknife:8.6.0'
        annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
        compile 'com.android.support:cardview-v7:25.3.1'
        // jCenter
        compile 'jp.wasabeef:recyclerview-animators:2.2.6'
        compile 'com.ncornette.cache:okcache-control:1.1.1'
        compile 'org.greenrobot:greendao:3.2.2'
        compile 'net.danlew:android.joda:2.9.9'
        compile 'com.github.barteksc:android-pdf-viewer:3.0.0-beta.3'
        compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
        compile 'org.jetbrains.anko:anko-common:0.8.3'
        compile 'me.dm7.barcodescanner:zbar:1.9.8'
        // https://mvnrepository.com/artifact/com.openhtmltopdf/openhtmltopdf-parent
        compile group: 'com.openhtmltopdf', name: 'openhtmltopdf-parent', version: '0.0.1-RC12', ext: 'pom'
    }

Main (Outer) build.gradle:

    buildscript {
    ext.kotlin_version = '1.2.0'
    repositories {
        jcenter()
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0-alpha06'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
        google()
    }
}


task clean(type: Delete) {
    delete rootProject.buildDir
}

This issue is not coming on Android Studio 3.0.1

Leave a Comment