如何从 react-native 项目中取消链接库

Yoe*_*oey 6 react-native

我按照安装说明安装了这个库(https://github.com/stefalda/ReactNativeLocalization

npm install react-native-localization --save
react-native link react-native-localization
Run Code Online (Sandbox Code Playgroud)

我不想再使用它了。我已经尝试了以下步骤将其从我的项目中删除:

npm unlink react-native-localization
npm uninstall react-native-localization --save
Run Code Online (Sandbox Code Playgroud)

我试着跑

react-native unlink react-native-localization
Run Code Online (Sandbox Code Playgroud)

但是,我收到错误消息 react-native-localization is not a react-native library.

当我运行时react-native run-android,出现以下错误:

Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve project :react-native-localization.
     Required by:
         project :app
      > Unable to find a matching configuration of project :react-native-localization:
          - None of the consumable configurations have attributes.
Run Code Online (Sandbox Code Playgroud)

Muh*_*faq 7

第一次运行

react-native unlink libraryname
Run Code Online (Sandbox Code Playgroud)

然后

npm uninstall libraryname
Run Code Online (Sandbox Code Playgroud)

或使用 yarn

yarn remove libraryname
Run Code Online (Sandbox Code Playgroud)

万一,如果它不起作用,那么

转到您的项目 android 目录并打开setting.gradle

并手动删除您的库配置。和

还要检查您的MainActivity.java以删除有关库的任何配置。

希望会有所帮助!!!

  • 当我们不再有 unlink 命令时,今天该怎么做呢?当我尝试时,我收到“错误无法识别的命令“取消链接”” (2认同)

Yoe*_*oey 1

好吧,我找到了解决方案。您必须删除 Android 项目的 build.gradle 文件中的引用以及 MainApplication.java 类中的任何引用。然后它对我有用