Advertisement

「react-native」【记】在真机(ios和安卓)上运行example项目AwesomeProject时遇到的问题

阅读量:

「react-native」【记】在真机(ios和安卓)上运行example项目AwesomeProject时遇到的问题

  • 问题一:Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.Please try again manually: "cd ./AwesomeProject/ios && pod install"
  • 问题二:The app identifier "org.reactjs.native.example.AwesomeProject" cannot be registered to your development team because it is not available. Change your bundle identifier to a unique string to try again.
  • 问题三:ios真机调试的时候,跳出提示框“未受信任的……开发者”
  • 问题四:开启小米开发者调试功能
  • 问题五:安卓(小米11)真机调试的时候,项目运行报错“Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.”

问题一:Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.Please try again manually: “cd ./AwesomeProject/ios && pod install”

学习react-native,根据官方文档配置好环境后,新建项目

复制代码
    npx react-native init AwesomeProject

时,报错,如图所示
报错1
根据命令提示输入

复制代码
    cd ./AwesomeProject/ios
    pod install

然而还是报错,如图所示
报错2
找了网上的帖子,并没有找到合适的解决方法,于是我按照官方文档中下载CocoaPods

复制代码
    brew install cocoapods

结果提示这玩意儿已经下载过了
在这里插入图片描述
然后我就按照上面的提示reinstall。然后把刚刚创建到一半的AwesomeProject文件夹删了,重新运行了一遍 npx react-native init AwesomeProject。然后就成功了……,也不清楚到底是为啥ORZ

问题二:The app identifier “org.reactjs.native.example.AwesomeProject” cannot be registered to your development team because it is not available. Change your bundle identifier to a unique string to try again.

在这里插入图片描述

这个问题就比较尴尬,属于是我自己没有仔细看报错信息。提示已经说了改个bundle identifier就行了。我想应该是大家创建这个项目的时候默认都是用的org.reactjs.native.example.AwesomeProject作为bundle identifier,肯定早就重复了吧,所以要自己取一个名字,改一下就行了。我改的格式是org.reactjs.native.xxx.test.AwesomeProject
,xxx那个地方放的是自己的名字拼音,然后点击Try Again就成功了。

问题三:ios真机调试的时候,跳出提示框“未受信任的……开发者”

这个就是给手机设置一下就可以啦,操作流程:设置=》通用=》描述文件与设备管理=》信任此开发者

问题四:开启小米开发者调试功能

  1. 使用USB连接Mac和小米手机
  2. 进入小米手机设置
  3. 点击「我的设备」
  4. 点击「全部参数」
  5. 连续点击10次「MIUI版本」(开启开发者模式)
  6. 回到「设置」首页
  7. 点击「更多设置」
  8. 点击「开发者选项」
  9. 打开「USB调试」、「USB安装」、「USB调试(安全设置)」
  10. 滑到最底部关闭「启用MIUI优化」

问题五:安卓(小米11)真机调试的时候,项目运行报错“Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.”

解决办法参考:[()

全部评论 (0)

还没有任何评论哟~