cordova android 打包环境

Created: Dec. 3, 2017, 10:20 a.m. Updated: June 4, 2018, 5:35 p.m.

Android SDK 安装

brew cask install android-sdk

编辑.base_profile设置环境

export ANDROID_SDK_ROOT="/usr/local/share/android-sdk

cordova增加android平台

cordova platform add android

打包

cordova build android

提示

Error: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle 
in your path, or install Android Studio

安装 gradle

brew install gradle

再次执行cordova build android 打包就可以了

apk输出路径

platforms/android/build/outputs/apk/android-debug.apk

二维码插件不支持 android

$ cordova plugin add cordova-plugin-qrscanner
Installing "cordova-plugin-qrscanner" for android
Installing "cordova-plugin-compat" for android
Plugin doesn't support this project's cordova-android version. cordova-android:
6.3.0, failed version requirement: 
<6.3.0
Skipping 'cordova-plugin-compat' for android

降低android版本

cordova platform update android@6.2