所以我今天打开了我的项目,准备导出并编译一个Android版本。
我运行了:react-原生运行-- android和./gradlew bundleRelease“和往常一样,但是现在它每次都会出错和失败。它仍然在iOS上工作,安卓部分没有做任何修改。
错误:
任务:react-native-navigation:compileReactNative68DebugJavaWithJavac失败/Users/xxxxxx/Documents/Github/YourProjectName/node_modules/react-native-navigation/lib/android/app/src/reactNative68/java/com/reactnativenavigation/react/NavigationReactNativeHost.java:错误:找不到符号.setUIImplementationProvider(getUIImplementationProvider())
有人知道我怎么解决这个问题吗?一直在尝试SO和GitHub (他们的回购)的所有答案。
使用Kotlin 1.6 (也尝试1.4.31 ) RN: 0.68.2
任何帮助都是非常感谢的!
编辑(解决方案)在android/build.gradle文件中添加以下内容
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}这一切都与https://github.com/facebook/react-native/issues/35210和https://github.com/wix/react-native-navigation/issues/7630有关
发布于 2022-11-05 20:32:01
我今天也面临着android构建的一个问题。虽然有不同的错误信息,但我怀疑您正在经历相同的核心问题。
首先,我注意到用于android的react原生版本是不正确的。要查看是否也是这样,请导航到终端(cd android)中的项目中的cd android文件夹,然后运行一个命令来生成依赖树:./gradlew app:dependencies > dep.txt。然后在文件dep.txt中搜索react-native:。如果react本机版本与您使用的版本(0.68.2)不匹配,那么将以下内容添加到顶级build.gradle文件中:
allprojects {
repositories {
+ exclusiveContent {
+ // We get React Native's Android binaries exclusively through npm,
+ // from a local Maven repo inside node_modules/react-native/.
+ // (The use of exclusiveContent prevents looking elsewhere like Maven Central
+ // and potentially getting a wrong version.)
+ filter {
+ includeGroup "com.facebook.react"
+ }
+ forRepository {
+ maven {
+ url "$rootDir/../node_modules/react-native/android"
+ }
+ }
+ }
// ...
}
}您可以在这里找到有关此问题的更多详细信息,https://github.com/facebook/react-native/issues/35210。
https://stackoverflow.com/questions/74326807
复制相似问题