とあるionic Cordovaアプリをビルドしたときに発生したエラーについて情報を残しておきます。
たぶん商用アプリでこのエラーに出会う人はいないと思う。
原因の概要
ionic Cordovaのアプリが古すぎて、
ビルドするために必要なNDKのバージョンが用意できていなかったため。
エラー内容
>ionic cordova run android -l
> ionic-app-scripts.cmd serve --address localhost --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser --iscordovaserve --platform android --target cordova
[app-scripts] [20:08:40] ionic-app-scripts 3.2.0
[app-scripts] [20:08:40] watch started ...
[app-scripts] [20:08:40] build dev started ...
[app-scripts] [20:08:40] Proxy added:/goto => http://xxx.xxx.xxx.xxx:xxxx/
[app-scripts] [20:08:40] clean started ...
[app-scripts] [20:08:40] clean finished in 31 ms
[app-scripts] [20:08:40] copy started ...
[app-scripts] [20:08:40] deeplinks started ...
[app-scripts] [20:08:40] deeplinks finished in 208 ms
[app-scripts] [20:08:40] transpile started ...
[app-scripts] [20:08:47] transpile finished in 6.51 s
[app-scripts] [20:08:47] preprocess started ...
[app-scripts] [20:08:47] preprocess finished in less than 1 ms
[app-scripts] [20:08:47] webpack started ...
[app-scripts] [20:08:47] copy finished in 7.18 s
[app-scripts] [20:08:52] webpack finished in 5.23 s
[app-scripts] [20:08:52] sass started ...
[app-scripts] [20:08:54] sass finished in 2.10 s
[app-scripts] [20:08:54] postprocess started ...
[app-scripts] [20:08:54] postprocess finished in 30 ms
[app-scripts] [20:08:54] lint started ...
[app-scripts] [20:08:54] build dev finished in 14.41 s
[app-scripts] [20:08:54] watch ready in 14.73 s
[INFO] Development server running!
Local: http://localhost:8100
Use Ctrl+C to quit this process
> cordova.cmd build android
[app-scripts] [20:09:03] lint finished in 8.47 s
[cordova]
[cordova] FAILURE: Build failed with an exception.
[cordova]
[cordova] * What went wrong:
[cordova] A problem occurred configuring project ':CordovaLib'.
[cordova] > No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
[cordova]
[cordova] * Try:
[cordova] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
[cordova]
[cordova] * Get more help at https://help.gradle.org
[cordova]
[cordova] BUILD FAILED in 3s
[cordova] cmd: Command failed with exit code 1 Error output:
[cordova] FAILURE: Build failed with an exception.
[cordova]
[cordova] * What went wrong:
[cordova] A problem occurred configuring project ':CordovaLib'.
[cordova] > No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
[cordova]
[cordova] * Try:
[cordova] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
[cordova]
[cordova] * Get more help at https://help.gradle.org
[cordova]
[cordova] BUILD FAILED in 3s
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
詳細
- エラー内容
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
「mips64el-linux-android」のNDK toolchainがないとのこと。
しかし、「mips64el-linux-android」は、NDK r17で、ドロップされた模様
https://github.com/android/ndk/wiki/Changelog-r17
※2020年の最新はNDK r21(21.3.6528147)
対象のNDKを探す
Android Studio 4.0で、NDKの古いバージョンを探す
→ Android SDK → SDK Tools → NDK にバージョンがなかった。
→ 手動でダウンロードする
※なかったと思ったけど、今、確認したら項目がありました。
あるなら、ここからインストールすればよいかと思います。以下からダウンロード
https://developer.android.com/ndk/downloads/older_releases
android-ndk-r16b-windows-x86_64.zip
展開したファイル類は、以下の場所とマッチします。
C:\Users[USER]\AppData\Local\Android\Sdk\ndk-bundle
ここの、「toolchains」配下に、「mips64el-linux-android-4.9」があれば、ビルドできるようになります。
補足
バージョンが古いので、本来ならば、ionic Cordova本体は関連パッケージすべて現環境に合ったバージョンに上げるのが望ましいです。
参考
https://developer.android.com/ndk/downloads/older_releases?hl=zh-en
Android NDK、リビジョン 16b(2017 年 12 月)
コメント