所以我今天打开了我的项目,准备导出并编译Android版本。
我运行:反应原生运行android和/gradlew-bundleRelease";就像我一直做的那样,但现在它每次都会出错和失败。它仍然在iOS上运行,并且没有对android部分进行任何更改。
错误:
任务:反应本机导航:compileReactNative68DebugJavaWithJavac失败/Users/xxxxxx/Documents/Github/YourProjectName/node_modules/areact native navigation/lib/android/app/src/reactNative68/java.com/reactactivenavigation/areactNavigationReactNativeHost.java:错误:找不到符号.setUIImplementationProvider(getUIImplementation Provider(((
有人知道我该怎么解决这个问题吗?一直在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
我今天也遇到了android版本的问题。虽然有不同的错误消息,但我怀疑您遇到了相同的核心问题。
首先,我注意到为android解析的react原生版本是不正确的。要查看是否也是这样,请导航到终端中项目中的android
文件夹(cd android
(,然后运行一个命令生成依赖树:./gradlew app:dependencies > dep.txt
。然后在文件dep.txt
中搜索react-native:
。如果react native的版本与您使用的版本不匹配(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