基本配置
// 聲明是Android程序
apply plugin: 'com.android.application'
android {
// 編譯SDK的版本
compileSdkVersion 21
// build tools的版本
buildToolsVersion "21.1.1"
defaultConfig {
// 應(yīng)用的包名
applicationId "me.storm.ninegag"
minSdkVersion 14 //支持的最小sdk
targetSdkVersion 21 //目標(biāo)sdk版本
versionCode 1 //版本號
versionName "1.0.0" // 版本名
}
// java版本
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {//編譯類型 分為debug、release
debug {
// debug模式
}
release {
// 是否進(jìn)行混淆
minifyEnabled false
// 混淆文件的位置
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
// 移除lint檢查的error
lintOptions {
abortOnError false
}
}
dependencies {
// 編譯libs目錄下的所有jar包
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.2'
//添加依賴
compile ‘xxxxxxx’
}
添加簽名均抽,配置簽名信息:
android.signingConfigs{}下定義一個或者多個簽名信息捻撑,然后在buildTypes{}配置使用即可。
android {
signingConfigs {
release {
storeFile file("xx.jks")
storePassword 'android'
keyAlias 'android'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.release
}
}
}
也可以看下圖:
signingconfig //簽名所用的配置文件
簽名打包:
命令 gradlew assembleDebug 或者 gradlew assembleRelease 進(jìn)行打包
多渠道(應(yīng)用寶价认、360應(yīng)用市場嗅定、小米)打包:?
build.gradle文件:productFlavors 多渠道打包。