首先肯定是配置gradle,百度一下就知道了,我的是mac下配置的,sudo vim ~/.bash_profile ,然后设置环境变量
GRADE_HOME=/Users/Admin/gradle;
export GRADE_HOME
export PATH=/opt/local/bin:/opt/local/sbin:$PATH:$GRADE_HOME/bin
最后保存,esc先退出,然后:qw!对了编辑的快捷键是i
接下来gradle -version 看是否配置成功
然后就是打开Android studio ,在build.gradle中配置一下如下
//渠道 productFlavors { baiduwuxian { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "baiduwuxian"] } } //多渠道打包 productFlavors { baiduwuxian {} productFlavors.all { flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name] } } //签名 signingConfigs { release { storeFile file('./singer/android.keystore') storePassword "android" keyAlias "mykey" keyPassword "android" } } lintOptions { checkReleaseBuilds false // Or, if you prefer, you can continue to check for errors in release builds, // but continue the build even when errors are found: abortOnError false } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 }
OK,然后需要在Terminal中输入命令:gradle clean,然后完成后再输入gradle assembleRelease
OK,大功告成。