Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Error - Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT error

enter image description here

This is my build.gradle (Module:app) file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false

    defaultConfig {
        applicationId "com.doctor.ciao"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.felipecsl:gifimageview:2.1.0'
    compile 'com.github.devlight.pulseview:library:1.0.2'
    compile 'commons-io:commons-io:2.4'
    compile 'com.github.lguipeng:BubbleView:1.0.1'

}

I am getting two errors:

  1. Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT error

  2. Error:Execution failed for task ':app:mergeDebugResources'.

    Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT error

I have already added "android.enableAapt2=false" to gradle.properties file but still the error persists. Please help me with this issue. Thank you

like image 876
Anubhav Sarangi Avatar asked Mar 14 '26 18:03

Anubhav Sarangi


1 Answers

My issue was that I had an invalid png file - I had a .jpg file that was accidentally renamed with the .png extension

To find the offending image file I ran this command in my app directory:

find . -type f -name "*.png" | xargs -L 1 -I{} file  -I {} | grep -v 'image/png; charset=binary$'

Renaming the image file to a .jpg extension solved the problem and I could build again.

like image 139
Airman00 Avatar answered Mar 16 '26 07:03

Airman00



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!