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 {
//设置支持的SO库架构
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 {
// 设置为true会关闭lint分析进度
quiet true
// 如果为true,则在发现错误时停止gradle构建
abortOnError false
// 如果为true,则只报告错误
ignoreWarnings true
}
buildTypes {//两种类型,这里可以使用不同的名字,然后在src下建立相同的名字,在打包的时候会去找相同名字的文件,如果找不到,就去找main默认文件件,可以作为替换资源文件时打包使用。
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: '')
}
}
}
}
在整个项目中的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]
}
}