我已經嘗試了很多解決方案,但都是徒勞的,包括這個 React Native Android 構建失敗,由于發布了 React Native 版本 0.71.0-rc.0,過去幾天沒有任何代碼更改,出現不同的 錯誤從過去 4 天開始沒有建立,任何幫助將不勝感激。
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.activity:activity-compose:1.4.0.
AAR metadata file: /Users/dev/.gradle/caches/transforms-2/files-2.1/c35837abe789834d04f87678613d3ab9/jetified-activity-compose-1.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
我試過 compileSdkVersion = 31 targetSdkVersion = 31 之后我得到
Execution failed for task ':react-native-incall-manager:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
我的 build.gradle 檔案是
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
androidXCore = "1.7.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.1")
// 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' }
}
}
React 原生版本是“^0.66.3”
uj5u.com熱心網友回復:
您的應用程式在正確之前運行良好,請按照以下步驟檢查
- 恢復您之后所做的所有更改(如果您更改了 sdk、gradle、java、react-native 等的版本)
- 洗掉
node_modules - 洗掉構建檔案夾 (
android/build&android/app/build) - 重新檢查版本是否與之前
package.json的react-native版本相同(在您的情況下0.66.3) - 運行
npm install或yarn安裝軟體包 - 清理(??洗掉此處提到的 gradle 快取:https ://stackoverflow.com/a/30450020/10657559 )并通過將以下更改添加到您的
android/build.gradle檔案來重建應用程式
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
buildscript {
// ...
}
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" REACT_NATIVE_VERSION
}
}
// ...
}
參考:修復和更新自 2022 年 11 月 4 日以來發生的 Android 構建失敗 #35210
uj5u.com熱心網友回復:
這是 gradle 服務器的問題。有許多官方修復正在啟動。您可以將 react-native 升級到 0.70.5,也可以使用此處提供的修復對其進行修補。https://github.com/facebook/react-native/issues/35249
uj5u.com熱心網友回復:
自 2022 年 11 月 4 日星期五以來,由于 react-native 出現了一些問題。更新您的 react-native 版本可以解決它。
注意:無需為此問題更新 gradle 檔案。
此處提到了 RN 的所有修復版本。
Ex: if you are on 0.64.3, change to 0.64.4
參考:https ://github.com/facebook/react-native/issues/35210
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/531169.html
標籤:安卓反应式
上一篇:ReactNative:捆綁ID和包名稱可以不同嗎?
下一篇:MVC表單資料無法系結到模型
