我正在开发一个 React Native 项目,需要将compileSdkVersion 和 targetSdkVersion 从 33 更新到 34。以下是我的 build.gradle 文件和 gradle-wrapper.properties 中的当前配置:
android/build.gradle
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 24
compileSdkVersion = 34
targetSdkVersion = 34
firebaseMessagingVersion = "21.1.0"
androidXCore = "1.6.0"
ndkVersion = "21.4.7075529"
}
repositories {
.....
}
dependencies {
classpath('com.android.tools.build:gradle:4.1.3')
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
环境:
React Native 版本:0.63.5 NDK 版本:21.4.7075529
我尝试过的:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-4.1.3-6503028-windows Daemon #0: Unexpected error during link, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
问题:
在我的 React Native 项目中将compileSdkVersion 和 targetSdkVersion 从 33 更新到 34,同时确保与我当前的构建设置兼容的最佳方法是什么?具体来说,我想要以下方面的指导:
预先感谢您的协助!
您需要将 buildToolsVersion 更新为 34.0.0。
buildToolsVersion = "34.0.0"
还必须要求将 com.android.tools.build:gradle 更新到 7.4.2。
classpath('com.android.tools.build:gradle:7.4.2')
例如。
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 24
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "21.4.7075529"
androidXCore = "1.6.0"
}
repositories {
...
}
dependencies {
classpath('com.android.tools.build:gradle:7.4.2')
...
}
}
它对我有用......!!!