Windowsでionicの次のコマンドでAndroidのapkを作成しようとしたときに発生したエラーを解決しましたので、簡易的なメモですが備忘のため記録します。
ionic cordova build android
対処概要
- Android Studio インストール
- adbのパスを環境変数に追加
- javaのパスを環境変数に追加
- Android イメージダウンロード
対処内容
Android Studio インストール
以下のURLの「DOWNLOAD ANDROID STUDIO」ボタンをクリックしてダウンロード。
ダウンロードしたファイルを実行してインストール。
adbのパスを環境変数に追加
以下のパスを環境変数に追加。
C:\Users\[ユーザー名]\AppData\Local\Android\Sdk\platform-tools
javaのパスを環境変数に追加
以下のパスを環境変数に追加。
※Javaを他で利用していないため、Android Studio依存のパスですが許容しています
C:\Program Files\Android\Android Studio\jre\bin
Android イメージダウンロード
以下のエラーが出た場合には、
対象のイメージがダウンロードできていないのでダウンロードします。
BUILD FAILED in 1m 41s
cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 27].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
Android Studioで初めてプロジェクトを作成して、
エミュレータで実行するときに規約に同意してイメージをダウンロードすれば
OKでした。
成功すると次のようなメッセージが表示されます。
BUILD SUCCESSFUL in 1s
46 actionable tasks: 1 executed, 45 up-to-date
Built the following apk(s):
[プロジェクトルート]\platforms\android\app\build\outputs\apk\debug\app-debug.apk
何かのお役に立てれば幸いです。