cordova でのスマホアプリ開発 ２

## まだ環境構築

https://ionicframework.com/jp/docs/installation/cli
https://cordova.apache.org/docs/ja/9.x/guide/cli/index.html



##### Ionic のインストール

```
C:\cordova_app>npm install -g ionic
npm WARN deprecated superagent@4.1.0: Please note that v5.0.1+ of superagent removes User-Agent header by default, therefore you may need to add it yourself (e.g. GitHub blocks requests without a User-Agent header).  This notice will go away with v5.0.2+ once it is released.
C:\Users\****\AppData\Roaming\npm\ionic -> C:\Users\****\AppData\Roaming\npm\node_modules\ionic\bin\ionic
+ ionic@5.2.1
added 224 packages from 167 contributors in 11.249s

C:\cordova_app>
```

環境を確認

```
C:\cordova_app>
C:\cordova_app>ionic info
[WARN] You are not in an Ionic project directory. Project context may be missing.

Ionic:

   Ionic CLI : 5.2.1

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v10.16.0
   npm    : 6.9.0
   OS     : Windows 10


C:\cordova_app>
```



##### アプリケーションの作成

```
C:\cordova_app>ionic start helloIonic

Let's pick the perfect starter template!

Starter templates are ready-to-go Ionic apps that come packed with everything you need to build your app. To bypass this
prompt next time, supply template, the second argument to ionic start.

? Starter template: tabs
√ Preparing directory .\helloIonic - done!
√ Downloading and extracting tabs starter - done!

Installing dependencies may take several minutes.

  ──────────────────────────────────────────────────────────────────────

      Ionic Enterprise, platform and solutions for teams by Ionic

                  Powerful library of native APIs
                 A supercharged platform for teams
       Bring your company's designs to life with Design Systems

         Learn more: https://ion.link/enterprise

  ──────────────────────────────────────────────────────────────────────


> npm.cmd i

> node-sass@4.12.0 install C:\cordova_app\helloIonic\node_modules\node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.12.0/win32-x64-64_binding.node
Download complete  ] - :
Binary saved to C:\cordova_app\helloIonic\node_modules\node-sass\vendor\win32-x64-64\binding.node
Caching binary to C:\Users\****\AppData\Roaming\npm-cache\node-sass\4.12.0\win32-x64-64_binding.node

> core-js@2.6.9 postinstall C:\cordova_app\helloIonic\node_modules\core-js
> node scripts/postinstall || echo "ignore"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> node-sass@4.12.0 postinstall C:\cordova_app\helloIonic\node_modules\node-sass
> node scripts/build.js

Binary found at C:\cordova_app\helloIonic\node_modules\node-sass\vendor\win32-x64-64\binding.node
Testing binary
Binary is fine
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 1121 packages from 1050 contributors and audited 54002 packages in 55.344s
found 0 vulnerabilities

> git.exe init
Initialized empty Git repository in C:/cordova_app/helloIonic/.git/
> git.exe add -A
> git.exe commit -m "Initial commit" --no-gpg-sign

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got '****.(none)')
[WARN] Error encountered during commit. Disabling further git operations.

[INFO] Next Steps:

       - Go to your newly created project: cd .\helloIonic
       - Run ionic serve within the app directory to see your app
       - Build features and components: https://ion.link/scaffolding-docs
       - Get Ionic DevApp for easy device testing: https://ion.link/devapp

C:\cordova_app>
```

途中、どのテンプレートを使用するか聞いてくるので、タブ構成を選択

? Starter template: tabs

他にもサイドメニュー、何もなし等が選べる（以下参照

```
Let's pick the perfect starter template!

Starter templates are ready-to-go Ionic apps that come packed with everything you need to build your app. To bypass this
prompt next time, supply template, the second argument to ionic start.

? Starter template: (Use arrow keys)
> tabs         | A starting project with a simple tabbed interface
  sidemenu     | A starting project with a side menu with navigation in the content area
  blank        | A blank starter project
  my-first-app | An example application that builds a camera with gallery
  conference   | A kitchen-sink application that shows off all Ionic has to offer
```



##### ブラウザでの動作確認

ionic 単体で web サービスを展開できるので、作成したテンプレートを動作確認

```
C:\cordova_app\helloIonic>ionic serve
> ng.cmd run app:serve --host=localhost --port=8100
[INFO] Waiting for connectivity with ng...

[INFO] Development server running!

       Local: http://localhost:8100

       Use Ctrl+C to quit this process

[INFO] Browser window opened to http://localhost:8100!

[ng] i ｢wdm｣: wait until bundle finished: /
[ng] Date: 2019-07-05T05:56:08.948Z
[ng] Hash: da8258facc59f811742d
[ng] Time: 11255ms
[ng] chunk {common} common.js, common.js.map (common) 14.1 kB  [rendered]
[ng] chunk {es2015-polyfills} es2015-polyfills.js, es2015-polyfills.js.map (es2015-polyfills) 285 kB [initial] [rendered]
[ng] chunk {main} main.js, main.js.map (main) 23.8 kB [initial] [rendered]
[ng] chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 237 kB [initial] [rendered]
[ng] chunk {runtime} runtime.js, runtime.js.map (runtime) 8.9 kB [entry] [rendered]
[ng] chunk {styles} styles.js, styles.js.map (styles) 68.4 kB [initial] [rendered]
[ng] chunk {tab1-tab1-module} tab1-tab1-module.js, tab1-tab1-module.js.map (tab1-tab1-module) 6.43 kB  [rendered]
[ng] chunk {tab2-tab2-module} tab2-tab2-module.js, tab2-tab2-module.js.map (tab2-tab2-module) 4.6 kB  [rendered]
[ng] chunk {tab3-tab3-module} tab3-tab3-module.js, tab3-tab3-module.js.map (tab3-tab3-module) 4.6 kB  [rendered]
[ng] chunk {tabs-tabs-module} tabs-tabs-module.js, tabs-tabs-module.js.map (tabs-tabs-module) 7.63 kB  [rendered]
[ng] chunk {vendor} vendor.js, vendor.js.map (vendor) 4.44 MB [initial] [rendered]
[INFO] ... and 96 additional chunks
[ng] i ｢wdm｣: Compiled successfully.

```

![test_ionic_server.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/464760/c3f23b6b-b6a5-12e5-98c1-135bb1d15dff.png)

終了は CTRL + c で

```
バッチ ジョブを終了しますか (Y/N)? y
```



##### エミュレータでの動作確認

プラットフォームを追加

```
C:\cordova_app\helloIonic>ionic cordova platform add android
> ionic integrations enable cordova
[INFO] Downloading integration cordova
[INFO] Copying integrations files to project
CREATE resources
CREATE resources\splash.png
CREATE resources\ios
CREATE resources\ios\splash
CREATE resources\ios\splash\Default~iphone.png
CREATE resources\ios\splash\Default@2x~universal~anyany.png
CREATE resources\ios\splash\Default@2x~iphone.png
CREATE resources\ios\splash\Default-Portrait~ipad.png
CREATE resources\ios\splash\Default-Portrait@~ipadpro.png
CREATE resources\ios\splash\Default-Portrait@2x~ipad.png
CREATE resources\ios\splash\Default-Landscape~ipad.png
CREATE resources\ios\splash\Default-Landscape@~ipadpro.png
CREATE resources\ios\splash\Default-Landscape@2x~ipad.png
CREATE resources\ios\splash\Default-Landscape-736h.png
CREATE resources\ios\splash\Default-736h.png
CREATE resources\ios\splash\Default-667h.png
CREATE resources\ios\splash\Default-568h@2x~iphone.png
CREATE resources\ios\icon
CREATE resources\ios\icon\icon@2x.png
CREATE resources\ios\icon\icon.png
CREATE resources\ios\icon\icon-small@3x.png
CREATE resources\ios\icon\icon-small@2x.png
CREATE resources\ios\icon\icon-small.png
CREATE resources\ios\icon\icon-83.5@2x.png
CREATE resources\ios\icon\icon-76@2x.png
CREATE resources\ios\icon\icon-76.png
CREATE resources\ios\icon\icon-72@2x.png
CREATE resources\ios\icon\icon-72.png
CREATE resources\ios\icon\icon-60@3x.png
CREATE resources\ios\icon\icon-60@2x.png
CREATE resources\ios\icon\icon-60.png
CREATE resources\ios\icon\icon-50@2x.png
CREATE resources\ios\icon\icon-50.png
CREATE resources\ios\icon\icon-40@3x.png
CREATE resources\ios\icon\icon-40@2x.png
CREATE resources\ios\icon\icon-40.png
CREATE resources\ios\icon\icon-1024.png
CREATE resources\icon.png
CREATE resources\android
CREATE resources\android\xml
CREATE resources\android\xml\network_security_config.xml
CREATE resources\android\splash
CREATE resources\android\splash\drawable-port-xxxhdpi-screen.png
CREATE resources\android\splash\drawable-port-xxhdpi-screen.png
CREATE resources\android\splash\drawable-port-xhdpi-screen.png
CREATE resources\android\splash\drawable-port-mdpi-screen.png
CREATE resources\android\splash\drawable-port-ldpi-screen.png
CREATE resources\android\splash\drawable-port-hdpi-screen.png
CREATE resources\android\splash\drawable-land-xxxhdpi-screen.png
CREATE resources\android\splash\drawable-land-xxhdpi-screen.png
CREATE resources\android\splash\drawable-land-xhdpi-screen.png
CREATE resources\android\splash\drawable-land-mdpi-screen.png
CREATE resources\android\splash\drawable-land-ldpi-screen.png
CREATE resources\android\splash\drawable-land-hdpi-screen.png
CREATE resources\android\icon
CREATE resources\android\icon\drawable-xxxhdpi-icon.png
CREATE resources\android\icon\drawable-xxhdpi-icon.png
CREATE resources\android\icon\drawable-xhdpi-icon.png
CREATE resources\android\icon\drawable-mdpi-icon.png
CREATE resources\android\icon\drawable-ldpi-icon.png
CREATE resources\android\icon\drawable-hdpi-icon.png
CREATE resources\README.md
CREATE config.xml
[OK] Integration cordova added!
√ Creating .\www directory for you - done!
> cordova.cmd platform add android
Using cordova-fetch for cordova-android@^8.0.0
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: io.ionic.starter
        Name: MyApp
        Activity: MainActivity
        Android target: android-28
Subproject Path: CordovaLib
Subproject Path: app
Android project created with cordova-android@8.0.0
Plugin 'cordova-plugin-whitelist' found in config.xml... Migrating it to package.json
Plugin 'cordova-plugin-statusbar' found in config.xml... Migrating it to package.json
Plugin 'cordova-plugin-device' found in config.xml... Migrating it to package.json
Plugin 'cordova-plugin-splashscreen' found in config.xml... Migrating it to package.json
Plugin 'cordova-plugin-ionic-webview' found in config.xml... Migrating it to package.json
Plugin 'cordova-plugin-ionic-keyboard' found in config.xml... Migrating it to package.json
Discovered saved plugin "cordova-plugin-whitelist". Adding it to the project
Installing "cordova-plugin-whitelist" for android

               This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.

Adding cordova-plugin-whitelist to package.json
Discovered saved plugin "cordova-plugin-statusbar". Adding it to the project
Installing "cordova-plugin-statusbar" for android
Adding cordova-plugin-statusbar to package.json
Discovered saved plugin "cordova-plugin-device". Adding it to the project
Installing "cordova-plugin-device" for android
Adding cordova-plugin-device to package.json
Discovered saved plugin "cordova-plugin-splashscreen". Adding it to the project
Installing "cordova-plugin-splashscreen" for android
Adding cordova-plugin-splashscreen to package.json
Discovered saved plugin "cordova-plugin-ionic-webview". Adding it to the project
Installing "cordova-plugin-ionic-webview" for android
Subproject Path: CordovaLib
Subproject Path: app
Adding cordova-plugin-ionic-webview to package.json
Discovered saved plugin "cordova-plugin-ionic-keyboard". Adding it to the project
Installing "cordova-plugin-ionic-keyboard" for android
Adding cordova-plugin-ionic-keyboard to package.json
[WARN] cordova-res was not found on your PATH. Please install it globally:

       npm i -g cordova-res

[WARN] Cannot generate resources without cordova-res installed.

       Once installed, you can generate resources with the following command:

       ionic cordova resources android --force

C:\cordova_app\helloIonic>
```

エミュレータで実行

```
C:\cordova_app\helloIonic>ionic cordova run android -l
[ERROR] native-run was not found on your PATH. Please install it globally:

        npm i -g native-run


C:\cordova_app\helloIonic>
```

警告を無視するとエラーになります



##### native-run のインストール

```
C:\cordova_app\helloIonic>npm i -g native-run
C:\Users\****\AppData\Roaming\npm\native-run -> C:\Users\****\AppData\Roaming\npm\node_modules\native-run\bin\native-run
+ native-run@0.2.7
added 30 packages from 33 contributors in 3.025s

C:\cordova_app\helloIonic>
```



##### エミュレータでの動作確認２回目

```
C:\cordova_app\helloIonic>ionic cordova run android -l
> ng.cmd run app:ionic-cordova-serve --host=localhost --port=8100 --platform=android
[INFO] Waiting for connectivity with ng...

[INFO] Development server running!

       Local: http://localhost:8100

       Use Ctrl+C to quit this process

> cordova.cmd build android
[ng] Date: 2019-07-05T06:09:40.303Z
[ng] Hash: da8258facc59f811742d
[ng] Time: 11456ms
[ng] chunk {common} common.js, common.js.map (common) 14.1 kB  [rendered]
[ng] chunk {cordova} cordova.js, cordova.js.map (cordova) 62.4 kB [entry] [rendered]
[ng] chunk {es2015-polyfills} es2015-polyfills.js, es2015-polyfills.js.map (es2015-polyfills) 285 kB [initial] [rendered]
[ng] chunk {main} main.js, main.js.map (main) 23.8 kB [initial] [rendered]
[ng] chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 237 kB [initial] [rendered]
[ng] chunk {runtime} runtime.js, runtime.js.map (runtime) 8.9 kB [entry] [rendered]
[ng] chunk {styles} styles.js, styles.js.map (styles) 68.4 kB [initial] [rendered]
[ng] chunk {tab1-tab1-module} tab1-tab1-module.js, tab1-tab1-module.js.map (tab1-tab1-module) 6.43 kB  [rendered]
[ng] chunk {tab2-tab2-module} tab2-tab2-module.js, tab2-tab2-module.js.map (tab2-tab2-module) 4.6 kB  [rendered]
[ng] chunk {tab3-tab3-module} tab3-tab3-module.js, tab3-tab3-module.js.map (tab3-tab3-module) 4.6 kB  [rendered]
[ng] chunk {tabs-tabs-module} tabs-tabs-module.js, tabs-tabs-module.js.map (tabs-tabs-module) 7.63 kB  [rendered]
[ng] chunk {vendor} vendor.js, vendor.js.map (vendor) 4.44 MB [initial] [rendered]
[INFO] ... and 96 additional chunks
[ng] i ｢wdm｣: Compiled successfully.
[cordova] ????:C:\cordova_app\helloIonic\platforms\android\CordovaLib\src\org\apache\cordova\engine\SystemCookieManager.java??????API???g?p?????I?[?o?[???C?h?????????B
[cordova] ????:????A-Xlint:deprecation?I?v?V???????w?????R???p?C??????????????B
[cordova] ????:???????t?@?C????????API???g?p?????I?[?o?[???C?h?????????B
[cordova] ????:????A-Xlint:deprecation?I?v?V???????w?????R???p?C??????????????B
> native-run.cmd android --app platforms\android\app\build\outputs\apk\debug\app-debug.apk --connect --forward 8100:8100
[native-run] No hardware devices found, attempting emulator...
[native-run] Selected emulator emulator-5554
[native-run] Forwarded device port 8100 to host port 8100
[native-run] Installing platforms\android\app\build\outputs\apk\debug\app-debug.apk...
[native-run] Starting application activity io.ionic.starter/io.ionic.starter.MainActivity...
[native-run] Run Successful
[native-run] Waiting for app to close...
```

エミュレータが起動し、作成したテンプレートが表示される
![test_ionic_nativerun.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/464760/c0d20eb6-2d10-6a43-b799-fca9dda8a493.png)


##### エミュレータでの動作確認３回目

アプリケーションとして展開してみる

```
C:\cordova_app\helloIonic>ionic cordova run android --native-run
> ng.cmd run app:ionic-cordova-build --platform=android

Date: 2019-07-05T07:39:31.162Z
Hash: 29516cdac4e0f8f56205
Time: 10070ms
chunk {0} 0.js, 0.js.map () 19.8 kB  [rendered]
chunk {1} 1.js, 1.js.map () 14.4 kB  [rendered]
chunk {2} 2.js, 2.js.map () 41.8 kB  [rendered]
chunk {3} 3.js, 3.js.map () 2.14 kB  [rendered]
chunk {4} 4.js, 4.js.map () 2.88 kB  [rendered]
chunk {5} 5.js, 5.js.map () 13.3 kB  [rendered]
chunk {6} 6.js, 6.js.map () 1.8 kB  [rendered]
chunk {7} 7.js, 7.js.map () 2.69 kB  [rendered]
chunk {8} 8.js, 8.js.map () 207 kB  [rendered]
chunk {9} 9.js, 9.js.map () 6.03 kB  [rendered]
chunk {10} 10.js, 10.js.map () 16.4 kB  [rendered]
chunk {11} 11.js, 11.js.map () 20.7 kB  [rendered]
chunk {12} 12.js, 12.js.map () 26.3 kB  [rendered]
chunk {13} 13.js, 13.js.map () 14.1 kB  [rendered]
chunk {14} 14.js, 14.js.map () 21.4 kB  [rendered]
chunk {15} 15.js, 15.js.map () 18.4 kB  [rendered]
chunk {16} 16.js, 16.js.map () 30.5 kB  [rendered]
chunk {17} 17.js, 17.js.map () 30.6 kB  [rendered]
chunk {18} 18.js, 18.js.map () 46 kB  [rendered]
chunk {19} 19.js, 19.js.map () 39.2 kB  [rendered]
chunk {20} 20.js, 20.js.map () 39.4 kB  [rendered]
chunk {21} 21.js, 21.js.map () 6.06 kB  [rendered]
chunk {22} 22.js, 22.js.map () 6.12 kB  [rendered]
chunk {23} 23.js, 23.js.map () 11.4 kB  [rendered]
chunk {24} 24.js, 24.js.map () 12 kB  [rendered]
chunk {25} 25.js, 25.js.map () 4.24 kB  [rendered]
chunk {26} 26.js, 26.js.map () 4.23 kB  [rendered]
chunk {27} 27.js, 27.js.map () 25 kB  [rendered]
chunk {28} 28.js, 28.js.map () 25.1 kB  [rendered]
chunk {29} 29.js, 29.js.map () 14.3 kB  [rendered]
chunk {30} 30.js, 30.js.map () 14 kB  [rendered]
chunk {31} 31.js, 31.js.map () 9.42 kB  [rendered]
chunk {32} 32.js, 32.js.map () 9.48 kB  [rendered]
chunk {33} 33.js, 33.js.map () 6.11 kB  [rendered]
chunk {34} 34.js, 34.js.map () 6.1 kB  [rendered]
chunk {35} 35.js, 35.js.map () 17.5 kB  [rendered]
chunk {36} 36.js, 36.js.map () 74 kB  [rendered]
chunk {37} 37.js, 37.js.map () 73.6 kB  [rendered]
chunk {38} 38.js, 38.js.map () 21.7 kB  [rendered]
chunk {39} 39.js, 39.js.map () 20.9 kB  [rendered]
chunk {40} 40.js, 40.js.map () 4.4 kB  [rendered]
chunk {41} 41.js, 41.js.map () 15 kB  [rendered]
chunk {42} 42.js, 42.js.map () 15 kB  [rendered]
chunk {43} 43.js, 43.js.map () 16 kB  [rendered]
chunk {44} 44.js, 44.js.map () 15.8 kB  [rendered]
chunk {45} 45.js, 45.js.map () 31.9 kB  [rendered]
chunk {46} 46.js, 46.js.map () 31.7 kB  [rendered]
chunk {47} 47.js, 47.js.map () 44.1 kB  [rendered]
chunk {48} 48.js, 48.js.map () 47.7 kB  [rendered]
chunk {49} 49.js, 49.js.map () 12.8 kB  [rendered]
chunk {50} 50.js, 50.js.map () 12.6 kB  [rendered]
chunk {51} 51.js, 51.js.map () 53 kB  [rendered]
chunk {52} 52.js, 52.js.map () 53.1 kB  [rendered]
chunk {53} 53.js, 53.js.map () 15.7 kB  [rendered]
chunk {54} 54.js, 54.js.map () 15.7 kB  [rendered]
chunk {55} 55.js, 55.js.map () 40.2 kB  [rendered]
chunk {56} 56.js, 56.js.map () 20.8 kB  [rendered]
chunk {57} 57.js, 57.js.map () 20.3 kB  [rendered]
chunk {58} 58.js, 58.js.map () 13.1 kB  [rendered]
chunk {59} 59.js, 59.js.map () 13.1 kB  [rendered]
chunk {60} 60.js, 60.js.map () 13.1 kB  [rendered]
chunk {61} 61.js, 61.js.map () 13.3 kB  [rendered]
chunk {62} 62.js, 62.js.map () 23.5 kB  [rendered]
chunk {63} 63.js, 63.js.map () 24.9 kB  [rendered]
chunk {64} 64.js, 64.js.map () 22 kB  [rendered]
chunk {65} 65.js, 65.js.map () 22 kB  [rendered]
chunk {66} 66.js, 66.js.map () 15.6 kB  [rendered]
chunk {67} 67.js, 67.js.map () 15.6 kB  [rendered]
chunk {68} 68.js, 68.js.map () 8.02 kB  [rendered]
chunk {69} 69.js, 69.js.map () 27.1 kB  [rendered]
chunk {70} 70.js, 70.js.map () 24.7 kB  [rendered]
chunk {71} 71.js, 71.js.map () 17.4 kB  [rendered]
chunk {72} 72.js, 72.js.map () 17 kB  [rendered]
chunk {73} 73.js, 73.js.map () 28.7 kB  [rendered]
chunk {74} 74.js, 74.js.map () 28.7 kB  [rendered]
chunk {75} 75.js, 75.js.map () 46.4 kB  [rendered]
chunk {76} 76.js, 76.js.map () 46.4 kB  [rendered]
chunk {77} 77.js, 77.js.map () 9.47 kB  [rendered]
chunk {78} 78.js, 78.js.map () 7.38 kB  [rendered]
chunk {79} 79.js, 79.js.map () 7.38 kB  [rendered]
chunk {80} 80.js, 80.js.map () 16.1 kB  [rendered]
chunk {81} 81.js, 81.js.map () 16.4 kB  [rendered]
chunk {82} 82.js, 82.js.map () 2.35 kB  [rendered]
chunk {83} 83.js, 83.js.map () 13.9 kB  [rendered]
chunk {84} 84.js, 84.js.map () 13.9 kB  [rendered]
chunk {85} 85.js, 85.js.map () 19.6 kB  [rendered]
chunk {86} 86.js, 86.js.map () 20.2 kB  [rendered]
chunk {87} 87.js, 87.js.map () 13.5 kB  [rendered]
chunk {88} 88.js, 88.js.map () 12.9 kB  [rendered]
chunk {89} 89.js, 89.js.map () 23.2 kB  [rendered]
chunk {90} 90.js, 90.js.map () 9.61 kB  [rendered]
chunk {91} 91.js, 91.js.map () 2.79 kB  [rendered]
chunk {92} 92.js, 92.js.map () 19.1 kB  [rendered]
chunk {93} 93.js, 93.js.map () 138 kB  [rendered]
chunk {94} 94.js, 94.js.map () 20.6 kB  [rendered]
chunk {95} 95.js, 95.js.map () 19 kB  [rendered]
chunk {common} common.js, common.js.map (common) 14.1 kB  [rendered]
chunk {cordova} cordova.js, cordova.js.map (cordova) 62.4 kB [entry] [rendered]
chunk {es2015-polyfills} es2015-polyfills.js, es2015-polyfills.js.map (es2015-polyfills) 285 kB [initial] [rendered]
chunk {main} main.js, main.js.map (main) 22.5 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 237 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 8.9 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 68.4 kB [initial] [rendered]
chunk {tab1-tab1-module} tab1-tab1-module.js, tab1-tab1-module.js.map (tab1-tab1-module) 6.43 kB  [rendered]
chunk {tab2-tab2-module} tab2-tab2-module.js, tab2-tab2-module.js.map (tab2-tab2-module) 4.6 kB  [rendered]
chunk {tab3-tab3-module} tab3-tab3-module.js, tab3-tab3-module.js.map (tab3-tab3-module) 4.6 kB  [rendered]
chunk {tabs-tabs-module} tabs-tabs-module.js, tabs-tabs-module.js.map (tabs-tabs-module) 7.63 kB  [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 4.12 MB [initial] [rendered]
> cordova.cmd build android
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\****\AppData\Local\Android\Sdk (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app
> Task :app:preBuild UP-TO-DATE
> Task :CordovaLib:preBuild UP-TO-DATE
> Task :CordovaLib:preDebugBuild UP-TO-DATE
> Task :CordovaLib:checkDebugManifest UP-TO-DATE
> Task :CordovaLib:processDebugManifest UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :CordovaLib:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :CordovaLib:packageDebugRenderscript NO-SOURCE
> Task :app:compileDebugRenderscript UP-TO-DATE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:generateDebugSources UP-TO-DATE
> Task :CordovaLib:compileDebugRenderscript UP-TO-DATE
> Task :CordovaLib:generateDebugBuildConfig UP-TO-DATE
> Task :CordovaLib:generateDebugResValues UP-TO-DATE
> Task :CordovaLib:generateDebugResources UP-TO-DATE
> Task :CordovaLib:packageDebugResources UP-TO-DATE
> Task :CordovaLib:generateDebugRFile UP-TO-DATE
> Task :CordovaLib:prepareLintJar UP-TO-DATE
> Task :CordovaLib:generateDebugSources UP-TO-DATE
> Task :CordovaLib:javaPreCompileDebug UP-TO-DATE
> Task :CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
> Task :CordovaLib:processDebugJavaRes NO-SOURCE
> Task :CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:processDebugResources
> Task :app:compileDebugJavaWithJavac UP-TO-DATE
> Task :app:compileDebugNdk NO-SOURCE
> Task :app:compileDebugSources UP-TO-DATE
> Task :app:mergeDebugShaders UP-TO-DATE
> Task :app:compileDebugShaders UP-TO-DATE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :CordovaLib:mergeDebugShaders UP-TO-DATE
> Task :CordovaLib:compileDebugShaders UP-TO-DATE
> Task :CordovaLib:generateDebugAssets UP-TO-DATE
> Task :CordovaLib:packageDebugAssets UP-TO-DATE
> Task :app:mergeDebugAssets
> Task :app:validateSigningDebug UP-TO-DATE
> Task :app:signingConfigWriterDebug UP-TO-DATE
> Task :app:transformClassesWithDexBuilderForDebug UP-TO-DATE
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug UP-TO-DATE
> Task :app:transformDexArchiveWithDexMergerForDebug UP-TO-DATE
> Task :app:mergeDebugJniLibFolders UP-TO-DATE
> Task :CordovaLib:compileDebugNdk NO-SOURCE
> Task :CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
> Task :CordovaLib:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
> Task :CordovaLib:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
> Task :app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
> Task :app:packageDebug
> Task :app:assembleDebug
> Task :app:cdvBuildDebug

BUILD SUCCESSFUL in 4s
42 actionable tasks: 4 executed, 38 up-to-date
Built the following apk(s):
        C:\cordova_app\helloIonic\platforms\android\app\build\outputs\apk\debug\app-debug.apk
> native-run.cmd android --app platforms\android\app\build\outputs\apk\debug\app-debug.apk
No hardware devices found, attempting emulator...
Selected emulator emulator-5554
Installing platforms\android\app\build\outputs\apk\debug\app-debug.apk...
Starting application activity io.ionic.starter/io.ionic.starter.MainActivity...
Run Successful

C:\cordova_app\helloIonic>
```

native-run と同じようにテンプレートが起動

アプリを確認すると MyApp が追加されている

![test_ionic_run.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/464760/29193424-1939-a6ce-febe-e0613548621c.png)

apk ファイルも出力されているので、USB経由でダウンロードすれば実機でも動作する
C:\cordova_app\helloIonic\platforms\android\app\build\outputs\apk\debug
app-debug.apk



##### エミュレータが動作不安定

起動、停止を繰り返したり、放置していたりするとエミュレータがかなり不安定になる

エミュレータが起動しなくなる
Android Studio の Events に以下エラーが出力される
Emulator: emulator: ERROR: AdbHostServer.cpp:93: Unable to connect to adb daemon on port: 5037
※AVD Manager から Virtual Devices を入れなおした

エミュレータが固まる
真っ暗のまま動作しなく…
※再起動したり、AVD Manager から Virtual Devices を入れなおしたり

Android Studio 以外のエミュレータはどうなんだろ

[cordova でのスマホアプリ開発 ３](https://qiita.com/flour_planaria/items/de82c06ac75bc773bb3f)