朕最近又開始調(diào)研ionic了,半年沒用發(fā)現(xiàn)ionic cli已經(jīng)升級(jí)了,在執(zhí)行ionic cordova build android時(shí)居然失敗了,然后就打印了一堆錯(cuò)誤,最后說了一句Error:No installed build tools found. Please install the Android build tools version 19.1.0 or higher.
于是百度啊,然后看到一堆人說下載「Android SDK Bulid-tools 19.1.0」可以解決,可是試了一下。。沒用。又看見有人說把Bulid-tools文件夾里面的文件夾命名改成19這種,也沒有用。于是上Stack Overflow瞅了一眼,老外是這么說的:
1.Simply replaceSystem.getenv("ANDROID_HOME")with your real Android SDK path (but you should remember that SDK location differs on other PCs)
2.Setup correct path for$ANDROID_HOMEenvironment variable
3.You can set build tool version manually inbuild.gradlefiles and skip calling methods described above (be sure to setup it for all the modules in the app):?
android { buildToolsVersion "your_version_here" }
于是乎回就去配了一下android的環(huán)境變量,然后build,過了。問題解決。
這里順便說一下Mac下配置android的環(huán)境變量,老司機(jī)請(qǐng)忽略。
ANDROID_HOME環(huán)境變量
1.$ touch .bash_profile ? ? //創(chuàng)建一個(gè)配置文件
2.$ vi .bash_profile ? ? //使用vi編輯器編輯 .bash_profile
3.輸入 ? i ? ? //在vi編輯器里面輸入 i ?的意思是開始編輯。
4.粘貼這行代碼 ? ? export ANDROID_HOME=~/Library/Android/sdk
5.點(diǎn)擊esc并輸入 ? ? :wq ? ? //意為保存并推出vi編輯器
6.$ source ~/.bash_profile? ? //使其立即生效
7.& echo $ANDROID_HOME檢查此變量是否已正確設(shè)置。