我试图在 android studio 上构建我的应用程序,但我收到此错误 “AAPT2进程意外退出。错误输出”
我搜索了它并尝试了一切来解决这个问题,但对我没有帮助。
android studio版本:4.1.1 gradle版本:6.8-rc5
这是我的 gradle 文件:
// 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
}
这是 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'
}
最佳答案
所以,终于有人从 Twitter 帮助我解决了这个问题。
解决办法是:
导致该问题的主要原因是android gradle插件版本和gradle版本不稳定。 您可以通过文件菜单中的项目结构器轻松更改这些版本,也可以使用命令 ctrl + alt + shift + S 访问项目结构。
我的设置是这样的:
android gradle plugin version: 4.0.1
gradle version: 6.1.1
请注意,版本不应包含 alpha 或 beta。
您也可以使用这个link找出哪些 gradle 插件和 gradle vesrion 彼此适合
关于java - 我正在尝试构建我的应用程序,但收到此错误 : AAPT2 process unexpectedly exit. 错误输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65634588/