• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Aapt2Exception

To answer this we need more information. The full exception stack trace, plus any relevant code, and XML resource files.
 
Try to use the latest android studio from the stable channel. As of today it is version 3.2.1. Oh and I'm in a linux environment. Not sure if versions would be different per OS.

Make sure that gradle is at version 4.6. In gradle-wrapper.properties the distribution url should be as follows...
Code:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

The build.gradle file in the root of your project should look as follows and every line must be in this order...
Code:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'

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

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

If you have any custom png images in your app make sure they are proper png files. ie. If a jpeg has been renamed to png this will trigger aapt errors.

It is also good in these situations to clean the project and then rebuild it. This sometimes fixes random errors. Sometimes you'll need to try a couple times and it'll finally build without errors. Android studio still isn't perfect and tends to have the occasional bug that might trigger errors even if your code is clean. The worst is major AS updates that tend to break things sometimes and can be difficult to fix.
 
Back
Top Bottom