美文网首页
React-Native 问题合集

React-Native 问题合集

作者: 小青蛙的花 | 来源:发表于2020-11-06 11:06 被阅读0次

    iOS问题
    以下问题仅针对 iOS,如有 Android解决方案会有说明

    1. 依赖库 react-native-fetch-blob

    使用场景:登录界面动态图片验证码


    动态验证码.png

    常见错误:

    1. CocoaPods could not find compatible versions for pod "React/Core":
    [!] CocoaPods could not find compatible versions for pod "React/Core":
    In Podfile:
    react-native-fetch-blob (from `../node_modules/react-native-fetch-blob`) was resolved to 0.10., which depends on
    React/Core
    None of your spec sources contain a spec satisfying the dependency: `React/Core`.
    

    解决办法

    • cd 项目根目录,执行命令
     grep -rl "s.dependency 'React/Core'" node_modules/ | xargs sed -i '' 's=React/Core=React-Core=g'
    
    • pod install
    pod install
    
    1. react-native link 无效
      可能是因为版本问题,毕竟react-native-fetch-blob已经很久没有更新了,如果react-native link 无效,可以使用
    react-native link react-native-fetch-blob
    

    如果还是无效,可以Podfile添加

    pod 'react-native-fetch-blob', :path => '../node_modules/react-native-fetch-blob'
    

    Android问题

    MacOs
    react-native run-android
    出现了以下报错

    ➜   react-native run-android
    info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
    Jetifier found 8131 file(s) to forward-jetify. Using 8 workers...
    info JS server already running.
    info Installing the app...
    
    error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
    Error: spawn ./gradlew EACCES
        at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)
    

    解决办法:
    在项目目录下使用以下指令:

    chmod 755 android/gradlew
    

    相关文章

      网友评论

          本文标题:React-Native 问题合集

          本文链接:https://www.haomeiwen.com/subject/cxqtbktx.html