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

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.

主站蜘蛛池模板: 阿克陶县| 任丘市| 成武县| 丹阳市| 上饶市| 罗山县| 泸水县| 隆安县| 武汉市| 武安市| 乳山市| 张家界市| 宜黄县| 辛集市| 靖边县| 明水县| 崇州市| 临江市| 台北县| 岳阳县| 西乌珠穆沁旗| 浦城县| 会泽县| 平遥县| 云浮市| 嘉善县| 射洪县| 海晏县| 海安县| 漳州市| 凭祥市| 攀枝花市| 朝阳区| 蛟河市| 利津县| 平武县| 罗源县| 鄱阳县| 宁都县| 涟水县| 会理县|