Ionic使用记录
Ubuntu下
MacOSX下
在系统重装后一直没有使用ionic的开发,今天要尝试时在安装后发现竟然无法启动了,先通过brew安装了java,android-sdk,node。再安装ionic
1 2
| brew install node ; brew cask install java android-sdk npm i -g ionic cordova
|
在安装后执行
1 2 3
| ionic start test blank ionic cordova platform add android ionic cordova build android
|
在执行到第三步时就开始报错
1 2 3 4 5 6 7
| ✖ Running command - failed! [ERROR] An error occurred while running cordova build android (exit code 1): ANDROID_HOME=/usr/local/share/android-sdk/tools JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home Error: Requirements check failed for JDK 1.8 or greater
|
发现通过brew安装的java是9.0版,虽然是比1.8高,但ionic不认。只要重新下载jdk-8u144-macosx-x64.dmg并安装设置环境变量。再运行就提示
1 2 3
| * What went wrong: A problem occurred evaluating root project 'android'. > No installed build tools found. Install the Android build tools version 19.1.0 or higher.
|
此时再执行
1
| sdkmanager "build-tools;19.1.0" "platforms;android-26" "platforms;android-18" "platforms;android-19"
|
还是不认,最后发现系统的环境变量有误,最后修改环境变量为
1 2
| export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/ export ANDROID_HOME=/usr/local/share/android-sdk
|
此后可以正常执行了