ionic day01教程第一天之多平台运行(ios & android)

一、创建项目

  1. 创建项目

    ionic start myApp
    
  2. 运行项目
    (1)通过浏览器运行项目
    进入项目,后运行ionic serve

    cd myApp
    ionic serve
    

浏览器运行效果
ioni

二、多平台配置

  1. android和ios平台支持
$ ionic platform add ios
$ ionic platform add android

如果是ios请再安装个

$ npm install -g ios-sim
  1. 运行程序
$ ionic emulate ios
$ ionic emulate android

三、遇到问题

  1. Mac osx android安装时 模拟器有时需要运行权限 通常会报如下错误
Error launching emulator: Cannot run program "~/Library/Android/sdk/tools/emulator": error=13, Permission denied

解决方法 :由于在10.11之后,sdk被安装到Library目录下了,相关程序需要授予运行权限.

chmod a+x ~/Library/Android/sdk/tools/emulator
chmod a+x ~/Library/Android/sdk/tools/android
  1. android模拟器非常运行非常慢的问题
    在android中安装一下HAXM,这样有助于提高虚拟机运行速度

    under Extras, check the box next to "Intel x86 Emulator Accelerator (HAXM)."

    andriodhamx

  2. 如何检测android sdk是否安装好
    在命令行或terminal中输入

    $ android -v
    

    如果出现错误,可能时path路径没有设置好,可以通过$PATH命令查看,如果没有请添加路径。

    $ vi ~/.bash_profile
    $ source ~/.bash_profile
    

    注意 需要运行一下source否则不生效呦

关注我的订阅号
软件哥

原文地址:https://www.cnblogs.com/springday/p/5445447.html