当我尝试为生产构建此错误出现



当我尝试为生产构建时,出现了这个错误。我使用的是React Native Firebase。此错误发生在android上。

这里是错误

* What went wrong:
Execution failed for task ':react-native-firebase_app:generateReleaseRFile'.
> Could not resolve all files for configuration ':react-native-firebase_app:releaseCompileClasspath'.
> Failed to transform react-native-0.71.0-rc.0-release.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-symbol-with-package-name, com.android.build.api.attributes.BuildTypeAttr=release, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Could not find react-native-0.71.0-rc.0-release.aar (com.facebook.react:react-native:0.71.0-rc.0).
Searched in the following locations:
https://repo.maven.apache.org/maven2/com/facebook/react/react-native/0.71.0-rc.0/react-native-0.71.0-rc.0-release.aar

这是我的包裹

[tag:    "@react-native-async-storage/async-storage": "^1.17.10",
"@react-native-firebase/analytics": "^16.4.3",
"@react-native-firebase/app": "^16.4.3",
"@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13",
"@react-navigation/native-stack": "^6.9.1",
"@rneui/base": "^4.0.0-rc.7",
"@rneui/themed": "^4.0.0-rc.7",
"meilisearch": "^0.29.1",
"native-base": "^3.4.21",
"picomatch": "^2.3.1",
"react": "18.1.0",
"react-native": "0.70.3",
"react-native-firebase": "^5.6.0",
"react-native-google-mobile-ads": "^8.2.1",
"react-native-navigation-bar-color": "^2.0.1",
"react-native-safe-area-context": "^4.4.1",
"react-native-screens": "^3.18.2",
"react-native-svg": "^13.5.0",
"react-native-vector-icons": "^9.2.0"]

如果你能帮忙,谢谢!

我已经尝试了所有我能在网上找到的东西=(

我也试过npx jetify

试试这个

添加这些行到android/build。gradle文件

allprojects {
repositories {
google()
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}

}

这是react native的一个bug,已经发布修复。

检查https://github.com/facebook/react-native/issues/35210

我能够通过更新react native版本到最新的补丁来解决这个问题。

tbody> <<tr>
原生版本 更新到
0.70.x0.70.5
0.69.x0.69.7
0.68.x0.68.5
0.67.x0.67.5
0.66.x0.66.5
0.65.x0.65.3
0.64.x0.64.4
0.63.x0.63.5

确保你的应用/构建中的react-native版本。Gradle在package.json中匹配你的版本:

app/build.gradle

implementation "com.facebook.react:react-native:0.70.+"

package.json

"react-native": "0.70.5"

this works for me

你可以查看这个链接来了解到底是什么问题:没有匹配的com.facebook.react:react-native:0.71.0-rc的变体。

解决方案1:

把react native版本升级到0.71,然后npm install.

解决方案2:

我正在使用react原生版本0.69.4,这段代码帮助我通过添加到我的android/build来修复它。gradle文件。

allprojects {
repositories {
google()
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}

}

希望这篇文章对你和其他遇到这个问题的人有所帮助。

作为第一个回答说,它的问题在maven中心和react-native解决了这里https://github.com/facebook/react-native/issues/35210....在包中。json文件通过替换这一行

来更新react-native
"react-native": "0.70.5"

then NPM install

最新更新