zoukankan      html  css  js  c++  java
  • 关于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:
    ode
    ode.EXE
          Yarn: 1.16.0 - D:yarninyarn.CMD
          npm: 6.4.1 - D:
    ode
    pm.CMD

    解决方案

    1.清除yarn缓存 yarn cache clean
    2.清除npm缓存 npm cache clean -f
    3.在项目文件夹中有一个package.json 文件,里面记录了该项目所有安装的依赖环境,若项目文件出现依赖环境报错的情况,则可以删除依赖node_module文件夹,在重新yarn install 一次 , 重新安装依赖。
    4.对于项目出现出现.../.../debug/.../../文件夹报错,可能是缓存导致的问题,进入android文件夹下,输入命令 ./gradlew clean 命令清除缓存,也可使用android studio 中的菜单按钮的build下的clean project清除环境,在使用rebuild project 重新跑一次项目。
  • 相关阅读:
    maven 创建web项目出错
    poj1699--Best Sequence(dfs+剪枝)
    HDU-1042-N!(Java大法好 && HDU大数水题)
    “XXX.Index”不扩展类“System.Web.UI.Page”,因此此处不同意的问题
    scala模式匹配
    scala匿名函数
    scala特质
    group by的使用
    liux之我用过的zip解压命令
    liunx之zip格式的解压命令
  • 原文地址:https://www.cnblogs.com/songdongdong/p/10862065.html
Copyright © 2011-2022 走看看