Ref:
Maven仓库上查插件最新版本号
The Central Repository Search Engine
http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.greenrobot%22%20AND%20a%3A%22eventbus%22
Android studio 自定义打包apk名 - petercao - 博客园
http://www.cnblogs.com/bluestorm/p/6228085.html
Android打包的那些事
http://www.cnblogs.com/qianxudetianxia/p/4948499.html
Android Studio中gradle的一些玩法
http://blog.csdn.net/jiujiedexiaoming/article/details/54962436
Android开发之深入理解Android Studio构建文件build.gradle配
http://www.cnblogs.com/dazhao/p/6692416.html
自动化构建
如何使用jenkins打包android和ios,并上传到蒲公英平台
《使用jenkins自动化构建android和ios应用》
http://www.jayfeng.com/2015/10/22/%E4%BD%BF%E7%94%A8jenkins%E8%87%AA%E5%8A%A8%E5%8C%96%E6%9E%84%E5%BB%BAandroid%E5%92%8Cios%E5%BA%94%E7%94%A8/
1.全局变量的使用
ext {
//全局变量控制,可在module中的build.gradle文件通过rootProject.ext.xxx开头来使用
compileSdkVersion = 24
buildToolsVersion = '24.0.3'
supportVersion = '24.2.1'
//主程序版本
targetSdkVersion = 24
minSdkVersion = 15
versionCode = 1
versionName = "v1.0.0"
//library版本
jjdxm_minSdkVersion = 9
jjdxm_versionCode = 1
jjdxm_versionName = "v1.0.0"
jjdxm_v4 = 'com.android.support:support-v4:'+supportVersion
jjdxm_v7 = 'com.android.support:appcompat-v7:'+supportVersion
jjdxm_design = 'com.android.support:design:'+supportVersion
jjdxm_cardview = 'com.android.support:cardview:'+supportVersion
jjdxm_recyclerview = 'com.android.support:recyclerview-v7:'+supportVersion
}
module的build.gradle中调用全局变量中元素
apply plugin: 'com.android.library' android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig {
minSdkVersion rootProject.ext.jjdxm_minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.jjdxm_versionCode
versionName rootProject.ext.jjdxm_versionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" }
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
} dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile rootProject.ext.jjdxm_v7
compile rootProject.ext.jjdxm_design
}
sdk版本设置规则
minSdkVersion <= targetSdkVersion <= compileSdkVersion //(
版本号<=
小于等于)
minSdkVersion <= buildToolsVersion <= compileSdkVersion
2.配置打包用的签名
主要有接过分享或者授权登录功能的都应该知道,像微信或者微博的分享和授权登录提供sdk,只有在指定的签名下才能生效,而我们平时开发都习惯使用默认的androidkeystore打包签名,这个时候想要测试分享或者登录功能就需要手动去打包指定keystore的签名。非常影响开发效率,这个时候可以通过配置gradle,根据release或者是debug打包指定的签名。
项目根目录新建一个签名用到的密码管理文件signing.properties
signing.alias=dou361 #release
signing.password=dou361 #release
signing.jjdxm_alias=dou361 #debug
signing.jjdxm_password=dou361 #debug
在主程序build.gradle的apply plugin: ‘com.android.application’下面添加
Properties props = new Properties()
props.load(new FileInputStream(file(rootProject.file("signing.properties"))))
在android{}节点里面添加
signingConfigs {
release {
keyAlias props['signing.alias']
keyPassword props['signing.password']
storeFile file(rootProject.file("debug.keystore"))
storePassword props['signing.password']
} debug {
keyAlias props['signing.jjdxm_alias']
keyPassword props['signing.jjdxm_password']
storeFile file(rootProject.file("debug.keystore"))
storePassword props['signing.jjdxm_password']
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}