官术网_书友最值得收藏!

Building a dummy app

After successfully setting up the environment correctly, you must be excited to build your first app. In this section of the chapter, we will use the commands to learn how to create a sample Ionic-based Hybrid App and build it to run on an actual device or emulator:

  1. We will create the initial project using the Ionic start command and name our project MyFirstApp. The output will be as illustrated in the following screenshot:
    Building a dummy app
  2. After the successful creation of your project with the default Ionic template, go to your project folder using the command $ cd MyFirstApp.

    Now, as we are in an Ionic project folder, we can run Ionic project-specific CLI commands. Any platform can be added to the project to build the specific app:

    $ ionic platform add android
    

    We will add an Android platform as it will work on all machines, such as Windows, Linux, or Mac. Ionic will download Android-specific default resources such as icons and splash screens, and also add some important plugins by default. A customized keyboard plugin is bundled with the Ionic app.

  3. In order to test the app and view it in your browser, use the Ionic serve command:
    $ ionic serve
    

    This will open the Ionic app in your default browser.

    The latest Chrome version provides a way to emulate various mobile device screen sizes. Open Developer Tools (F12), select Console from the top-right corner, and select Emulation. You can alternatively select the mobile icon from the top-left corner of the window. Please see the following screenshot:

    Building a dummy app
  4. Now, we can build the Android App and run it on an actual device or emulator:
    $ ionic run android
    

    This will fire up the emulator if there is no connected device, then start the build process. It will generate the .apk file and then deploy it to the emulator or the connected device that is available.

    This would be a Eureka moment, seeing your first actual app on the device and playing with it. In the next section we discuss some of the common issues you may have faced during the process and provide solutions for them.

主站蜘蛛池模板: 台北市| 五河县| 阿克| 玉门市| 惠水县| 河南省| 藁城市| 贵德县| 蒙山县| 通州市| 宁强县| 凤凰县| 恭城| 海门市| 无为县| 临邑县| 蒙山县| 台湾省| 密云县| 樟树市| 乐山市| 广东省| 株洲县| 奉节县| 鄂州市| 彭州市| 东源县| 中方县| 武乡县| 旅游| 娱乐| 南江县| 安远县| 敦化市| 隆尧县| 咸宁市| 同心县| 迭部县| 若尔盖县| 贡觉县| 诸城市|