スポンサーリンク

Ionic3でandroidアプリのbuild

Ionic3でAndroidアプリをビルドしたい(apkファイルを作成したい)とき。

ionic cordova platform add android

ionic cordova build android --prod

で、以下のようなエラー。

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 26, Android SDK Build-Tools 26.0.2].
  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

見たことのないエラー。

(解決策)

AndroidStudioを開き、Tools > SDK Manager をクリック。

そして、以下の2つのチェックボックスをONにして、Applyをクリック > インストールする。

image

5分くらい時間がかかった。

その後、再度、

ionic cordova build android --prod

image

今度は、apkファイルを作成することができた。

image

このapp-debug.apk (約4MB)を自分のスマホにメールして、インストール。

(Androidスマホは、言われた通りに、提供元不明アプリのインストール可能な設定に変更しておく必要がある。)

Zenfone4 Maxで、無事、以下のコードからビルドしたTODOアプリが動いた。

https://github.com/adash333/ionic_tutorial

スポンサーリンク