首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RNN >任务:react-native-navigation:compileReactNative68DebugJavaWithJavac失败

RNN >任务:react-native-navigation:compileReactNative68DebugJavaWithJavac失败
EN

Stack Overflow用户
提问于 2022-11-05 10:05:58
回答 1查看 371关注 0票数 4

所以我今天打开了我的项目,准备导出并编译一个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文件中添加以下内容

代码语言:javascript
复制
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/35210https://github.com/wix/react-native-navigation/issues/7630有关

EN

回答 1

Stack Overflow用户

发布于 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文件中:

代码语言:javascript
复制
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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74326807

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档