5

Before I updated to android studio 3 and gradle 3.0.1 I could build my project without a problem, but ever since I updated I keep getting this errors:

Error:failed linking references.
    Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    Error:Execution failed for task ':app:processDebugResources'.
            > Failed to execute aapt

I tried to disable AAPT2 but then I get an error ProcessException for aapt

Error:java.util.concurrent.ExecutionException: 
com.android.ide.common.process.ProcessException: Error while executing 
process /build-tools/26.0.2/aapt with arguments {package -f --no-crunch 
-I /android-25/android.jar -M 

I tried to change compile to implementation and api but they all gave the same erros. Can someone please help me solve this...

Here is my gradle file:

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

        dependencies {
            classpath 'io.fabric.tools:gradle:1.+'
        }
    }

    buildscript {
        repositories {

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

        dependencies {
            classpath 'io.fabric.tools:gradle:1.+'
        }
    }
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'

    android {
        compileSdkVersion 25
        buildToolsVersion "26.0.0"
        defaultConfig {
            applicationId "com.trynagrub.trynagrub"
            minSdkVersion 21
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }


    dependencies {
        api fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        api files('libs/signalr-client-sdk.jar')
        api files('libs/signalr-client-sdk-android.jar')
        compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
            transitive = true;
        }
        compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
            transitive = true;
        }
        api 'org.zakariya.stickyheaders:stickyheaders:0.7.6'
        api 'net.danlew:android.joda:2.9.9'
        api 'com.hbb20:ccp:2.0.3'
        api 'com.squareup.picasso:picasso:2.5.2'
        api 'com.xw.repo:bubbleseekbar:3.6'
        api 'com.github.pavlospt:circleview:1.3'
        api 'com.facebook.android:facebook-android-sdk:[4,5)'
        api 'com.amitshekhar.android:android-networking:1.0.0'
        api 'de.hdodenhof:circleimageview:2.2.0'
        api 'com.android.support.constraint:constraint-layout:1.0.2'
        api 'com.github.stfalcon:chatkit:0.2.2'
        api 'com.google.android.gms:play-services-gcm:11.0.4'
        api 'com.snatik:storage:2.1.0'
        api 'com.github.tamir7.contacts:contacts:1.1.7'
        api 'com.google.android.gms:play-services-maps:11.0.4'
        testCompile 'junit:junit:4.12'
    }
    apply plugin: 'com.google.gms.google-services'
ben
  • 1,064
  • 3
  • 15
  • 29
  • I'm having a similar problem, but before the AAPT2 error messages, I get this error: C:\Users\joaoa\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.2.aar\f7f1208ccbeaf2068cb340236cc729d8\res\values\values.xml Error:(252, 5) error: duplicate value for resource 'attr/tint' with config ''. Do you know anything about this? – João Armando Dec 07 '17 at 15:10
  • @JoãoArmando With AAPT2 problem, check non-ascii characters don't exist in xml. – Toris Dec 07 '17 at 17:04
  • I'm also having a similar problem, I reinstalled android studio but till error is occurring – Yashoda Bane May 30 '19 at 12:53

4 Answers4

0

Use Build Tools 26.0.2 or higher.

Android Plugin for Gradle Release Notes

3.0.0 (October 2017)

This version of the Android plugin requires the following:
Gradle 4.1 or higher.
Build Tools 26.0.2 or higher.

NB: 3.0.0 is a version of Gradle plugin (in build.gradle of project).
4.1 is a version of Gradle (in gradle-wrapper.properties).


For information: AAPT2 related questions

  • corrupted manifest
    NB: You also have problems after disabling AAPT2, so these may not work for your case.

My Android manifest is full of errors after updating to Android 3.0.0 [duplicate] and
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

Element hierarchies in the Android manifest

In previous versions of AAPT, elements nested in incorrect nodes in the Android manifest are either ignored or result in a warning.

  • Non-ASCII or ' '(space) characters in gradle folder path
    NB: Same problem also occurs before upgrading in this case, I think.

…com.android.tools.aapt2.Aapt2Exception:.AAPT2 error:check logs for details and
Android Studio 3.0 migration AAPT2 error

Toris
  • 2,348
  • 13
  • 16
  • even after changing to 26.0.2 I still get that error, 'com.android.tools.build:gradle:3.0.0' this was also configured in the project – ben Dec 07 '17 at 16:13
0

Try this

Go to your gradle.properties

write the below code and Sync your project

android.enableAapt2=false
Android Geek
  • 8,956
  • 2
  • 21
  • 35
0

Sometimes xml files could cause problems.
Like style attributes are wrong or ....
In my case there was an invalid xml attr in styles.xml.

Mahdi-Malv
  • 16,677
  • 10
  • 70
  • 117
0

In my case the problem was that I had commented on a line that was in use, so when the compiler tried to find it, the error bounced.