首页 > 解决方案 > 将 React Native 代码集成到现有的 android 项目中

问题描述

将 react native 代码集成到现有的 android 项目中,遇到以下错误。

引起:java.lang.IllegalAccessError:方法'void androidx.core.net.ConnectivityManagerCompat.()

我们正在尝试将 react native 项目添加到现有的 android 应用程序中。使用以下参考链接:

https://medium.com/mindorks/react-native-integration-with-existing-app-f2757c2e672d

. 从 Android Main 活动切换到 Reactnative 活动时,我们得到以下异常

原因:java.lang.IllegalAccessError:方法 'void androidx.core.net.ConnectivityManagerCompat.()' 无法访问类 'com.facebook.react.modules.netinfo.NetInfoModule'('com.facebook.react. modules.netinfo.NetInfoModule`

. 请建议。

标签: androidreact-nativeintegration

解决方案


您链接到的指南已有 3 年历史,在那段时间里,RN(以及 Android、Gradle 等)发生了很多变化。

你可以试试这个指南:https ://blog.usejournal.com/integrating-react-native-with-existing-android-apps-efficiently-3b39f2e061bd吗?几周前我用过它,它对我有用。


推荐阅读