Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
844 views
in Technique[技术] by (71.8m points)

java - 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'

}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...