执行 com.android.build.gradle.internal.tasks.Workers$ActionFacade 时发生故障 AAPT2 aapt2-4.1.0-6503028-osx 守护进程 #0:链接期间出现意外错误,尝试停止守护进程。 正常情况下不会发生这种情况,如果发生,请提出问题。
运行时 =>npx react-native run-android 出现此错误 //android/build.gradle
buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
classpath('com.google.gms:google-services:4.3.8')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
我遇到了这个问题,并且在我的 build.gradle 中有一个非常相似的
classpath("com.android.tools.build:gradle:4.1.0")
行。我发现 this other question 使用的是 classpath 'com.android.tools.build:gradle:7.4.2'
,这让我很惊讶,因为 IDE 只建议最高版本 4.2.2。我将 AGP 插件更新到 7.3.1(我支持的最新 IDE 版本),并且应用程序构建得很好!也许这会帮助你解决这个难以理解的错误。