Search code examples
androidandroid-studioandroid-gradle-pluginandroid-studio-3.0aapt2

How to resolve AAPT2 error?


I am working on authentication through firebase since when I added implementation 'com.firebaseui:firebase-ui-auth:3.3.0' I am getting AAPT2 error: check logs for details error after syncing the gradle. Here are my build.gradle files.

build.gradle(app)

apply plugin: 'com.android.application'
repositories {
mavenLocal()
flatDir {
    dirs 'libs'
}
}

android {
compileSdkVersion 24
buildToolsVersion '27.0.3'

defaultConfig {
    applicationId "com.google.firebase.udacity.friendlychat"
    minSdkVersion 16
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE-FIREBASE.txt'
    exclude 'META-INF/NOTICE'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'

implementation 'com.android.support:design:24.2.1'
implementation 'com.android.support:appcompat-v7:24.2.1'


//  Firebase
implementation 'com.google.firebase:firebase-database:12.0.1'

implementation 'com.firebaseui:firebase-ui-auth:3.3.0'
implementation 'com.google.firebase:firebase-auth:12.0.1'

// Displaying images
implementation 'com.github.bumptech.glide:glide:3.6.1'
}

apply plugin: 'com.google.gms.google-services'

And build.gradle(Project)

// Top-level build file where you can add configuration options common to 
all sub-projects/modules.

buildscript {
repositories {
    jcenter()
    mavenLocal()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.0'
    classpath 'com.google.gms:google-services:3.2.1' // google-services 
plugin



    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
    mavenLocal()
    maven {
        url "https://maven.google.com" // Google's Maven repository
    }
}
}

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

The moment I delete this implementation 'com.firebaseui:firebase-ui-auth:3.3.0' the error is gone. I think adding this is creating AAPT2 error.

Google SDK Tools, Google Repository and Google Play Services are also installed. Please also explain what is this AAPT2 error and how this occur if possible.


Solution

  • Use this

    implementation 'com.android.support:design:27.0.3'
    implementation 'com.android.support:appcompat-v7:27.0.3'
    

    Instead of this

    implementation 'com.android.support:design:24.2.1'
    implementation 'com.android.support:appcompat-v7:24.2.1'
    

    Update compileSdkVersion 27 and targetSdkVersion 27