apply plugin: 'com.android.application'
apply plugin: 'com.antfortune.freeline'
apply plugin: 'maven'
android {
signingConfigs {
config {
storeFile file('')
storePassword ''
keyAlias ''
keyPassword ''
}
}
compileSdkVersion 23
buildToolsVersion '23.0.2'
dexOptions {
incremental true
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = true //delete the already predexed libraries
}
defaultConfig {
ndk {
//設(shè)置支持的SO庫架構(gòu)
abiFilters 'armeabi', 'armeabi-v7a', 'x86'//, 'armeabi-v7a', 'x86_64', 'arm64-v8a'
}
applicationId ""
minSdkVersion 15
targetSdkVersion 22
versionCode 11
versionName "2.3.0"
multiDexEnabled true
signingConfig signingConfigs.config
}
lintOptions {
// 設(shè)置為true會(huì)關(guān)閉lint分析進(jìn)度
quiet true
// 如果為true,則在發(fā)現(xiàn)錯(cuò)誤時(shí)停止gradle構(gòu)建
abortOnError false
// 如果為true,則只報(bào)告錯(cuò)誤
ignoreWarnings true
}
buildTypes {//兩種類型,這里可以使用不同的名字坷澡,然后在src下建立相同的名字榨惰,在打包的時(shí)候會(huì)去找相同名字的文件羡微,如果找不到攻冷,就去找main默認(rèn)文件件丈攒,可以作為替換資源文件時(shí)打包使用切揭。
release {
zipAlignEnabled true
shrinkResources true//移除無用的resource文件
minifyEnabled false//是否開啟混淆
shrinkResources //去除無用的resource文件
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'//加載混淆配置文件
debuggable false
signingConfig signingConfigs.config
}
debug {
manifestPlaceholders = [
UMENG_CHANNEL_VALUE: ,
QQ_APP_ID :"",//QQappid
QQ_APP_ID_VALUE :"",//
SHARE_SDK_VALUE :"",//sharesdk
TD_APP_ID_VALUE : "",//talkingdata
GETUI_APP_ID : "",
GETUI_APP_KEY : "",
GETUI_APP_SECRET : "",
JPUSH_KEY : "",
HUAWEI_KEY : "",
BAIDU_ID : "",
BAIDU_KEY : "",
XIAOMI_ID : "",
XIAOMI_KEY : "",
PACKAGE_NAME : ""]
minifyEnabled false
debuggable true
signingConfig signingConfigs.config
}
}
//修改打包名字
// applicationVariants.all { variant ->
// variant.outputs.each { output ->
// def outputFile = output.outputFile
// def fileName = "xuexitoutiao_v${defaultConfig.versionName}_${releaseTime()}.apk"
// output.outputFile = new File(outputFile.parent, fileName)
// }
// }
freeline {
hack true
productFlavor ""
}
productFlavors {
xxtt {
applicationId ""
manifestPlaceholders = [
UMENG_CHANNEL_VALUE: name,
QQ_APP_ID :"",//QQappid
QQ_APP_ID_VALUE :"",//
SHARE_SDK_VALUE :"",//sharesdk
TD_APP_ID_VALUE : "",//talkingdata
GETUI_APP_ID : "",
GETUI_APP_KEY : "",
GETUI_APP_SECRET : "",
JPUSH_KEY : "",
HUAWEI_KEY : "",
BAIDU_ID : "",
BAIDU_KEY : "",
XIAOMI_ID : "",
XIAOMI_KEY : "",
PACKAGE_NAME : ""]
}
}
}
def releaseTime() {
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile project(':my-image-browser')
compile project(':')
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri('')) {
authentication(userName: '', password: '')
}
snapshotRepository(url: uri('')) {
authentication(userName: '', password: '')
}
}
}
}
在整個(gè)項(xiàng)目中的build.gradle中 加入
def supportVersion = "23.2.1"
ext{
supportV4 = "com.android.support:support-v4:${supportVersion}"
appCompat = "com.android.support:appcompat-v7:${supportVersion}"
cardView = "com.android.support:cardview-v7:${supportVersion}"
designCompat = "com.android.support:design:${supportVersion}"
}
模塊中可以使用
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile rootProject.ext.appCompat
compile rootProject.ext.cardView
compile rootProject.ext.designCompat
compile project(':coverflow')
}
3.多渠道打包
productFlavors {
wandoujia {}
baidu {}
c360 {}
uc {}
productFlavors.all { flavor ->
flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
}
}