简体   繁体   中英

im trying to build my app but i getting this error: AAPT2 process unexpectedly exit. Error output

im trying to build my app on android studio but im getting this error "AAPT2 process unexpectedly exit. Error output"

i search about it and tryed everything to solve this but dosent help me.

android studio version:4.1.1 gradle version: 6.8-rc5

This is my gradle file:

// Top-level build file where you can add configuration options common          to all sub-projects/modules.
buildscript {
repositories {
    google()
    jcenter()
    mavenCentral()

}
dependencies {
    classpath 'com.android.tools.build:gradle:4.1.1'

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

And this is gradle(mudle)

    plugins {
        id 'com.android.application'
    }

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.weather5"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner    "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-  optimize.txt'), 'proguard-rules.pro'
    }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

}

So,finaly someone from Twitter helpd me and solve the problem.

The solution is:

The main cause of the problem is the instability of the android gradle plugin version and gradle version. You can easily change these versions through the project structcher from the file menu or you can use the command ctrl + alt + shift + S to reach project structur.

My setting is This:

android gradle plugin version: 4.0.1

gradle version: 6.1.1

Be aware that versions SHOULD NOT contain alpha or beta.

Also you can use this link to finde out Which gradle plugin and gradle vesrion are Suitable for each other

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM