关于react-native引入第三方库,运行react-native link xxxxx后项目无法运行

最新版本的react-native中,官方表示将要移除

AsyncStorage,推荐使用@react-native-community/async-storage,好吧官方经常这么干
 
按照官方提示
yarn add @react-native-community/async-storage
react-native link @react-native-community/async-storage
好吧,果然不负众望的报错了
错误信息如下
info Starting JS server...
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.google.gson.stream.MalformedJsonException: Invalid escape sequence at line 1 column 32 path $[0].name

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
76 actionable tasks: 1 executed, 75 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.

有关环境信息

info
  React Native Environment Info:
    System:
      OS: Windows 10
      CPU: (8) x64 Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
      Memory: 4.55 GB / 15.95 GB
    Binaries:
      Node: 10.15.3 - D:\node\node.EXE
      Yarn: 1.16.0 - D:\yarn\bin\yarn.CMD
      npm: 6.4.1 - D:\node\npm.CMD

好吧,经过半天的努力,我发现,如果我如果,我重新init一个新项目,并首先安装@react-native-community/async-storage,并没有问题,但是再次安装其他第三方库的时候,只要需要连接原生库,就必然出现上面 这个问题,100%重现,

这个问题折磨我了半天了,有没有知道怎么解决呢

猜你喜欢

转载自www.cnblogs.com/songdongdong/p/10862065.html