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 重新跑一次项目。
  • 相关阅读:
    使用TortoiseSVN建本地仓库20100114
    通用分布式缓存介绍
    fujishu的本真的挺好的
    春晚架构&Ylmf OS&Chrom OS
    sqlserver开发杂记20100120
    tsql使用小记20100127
    mac下hg的安装
    小毛新年祝辞——整装待发,为梦想行
    Memcached客户端评测报告20100125
    小毛iBatis.net保姆系列课程索引
  • 原文地址:https://www.cnblogs.com/songdongdong/p/10862065.html
Copyright © 2011-2022 走看看