Android build def,Android 关于build.gradle的一些配置问题

该博客详细介绍了Android应用的Gradle配置,包括打包设置、签名文件、版本控制、资源值设定、多 Dex 支持、内存优化以及编译加速等。此外,还涉及到不同构建类型和产品风味的定制,以及如何处理lint检查和解决MissingTranslation问题。
摘要由CSDN通过智能技术生成

apply plugin: 'com.android.application'

// 打包时间

static def buildTime() {

return new Date().format("yyyy-MM-dd-HH-mm-ss", TimeZone.getTimeZone("GMT+08:00"))

}

android {

compileSdkVersion 25

buildToolsVersion '27.0.3'

// 指定签名文件

signingConfigs {

test {

keyAlias 'test'

keyPassword 'test123'

storeFile file('../test.jks')

storePassword 'test123'

}

}

defaultConfig {

applicationId "top.tobin.game"

minSdkVersion 14

targetSdkVersion 25

versionCode 100

versionName "1.0.0"

// dex突破65535的限制

multiDexEnabled true

// 设置AndroidManifest.xml 里面icon 的value默认值

manifestPlaceholders = [app_icon : "@mipmap/ic_launcher"]

resValue "string", "app_name", "Game_Default"

}

//执行lint检查,有任何的错误或者警告提示,都会终止构建,我们可以将其关掉。

lintOptions {

checkReleaseBuilds false

abortOnError false

// 防止在发布的时候出现因MissingTranslation导致Build Failed!

disable 'MissingTranslation'

}

dexOptions {

javaMaxHeapSize "8g"

jumboMode = true

preDexLibraries = false

threadCount ="8"

}

allprojects {

// 加快 Android Studio 编译

tasks.withType(JavaCompile) {

// 使在一个单独的守护进程编译

options.fork = true

// 增量编译

options.incremental = true

}

repositories {

jcenter()

}

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

signingConfig signingConfigs.test

}

applicationVariants.all { variant ->

variant.outputs.all { output ->

def versionName = variant.versionName

def versionCode = variant.versionCode

def buildType = variant.buildType.name

if (variant.buildType.name == 'debug') {

outputFileName = "Game_${variant.flavorName}_${versionName}_${versionCode}_${buildType}.apk"

} else {

outputFileName = "Game_${variant.flavorName}_v${versionName}_${buildTime()}_${buildType}.apk"

}

}

}

}

flavorDimensions "default"

productFlavors {

dev {

dimension "default"

resValue "string", "app_name", "GameMultichannel"

applicationId 'top.tobin.game'

manifestPlaceholders = [ENVIRONMENT: "dev", app_icon : "@mipmap/ic_launcher"]

}

common {

dimension "default"

applicationId 'top.tobin.game.commonsdk'

versionCode 101

versionName "1.0.1"

resValue "string", "app_name", "Game_Common"

}

ysdk {

dimension "default"

applicationId 'top.tobin.game.tencent'

versionCode 105

versionName "1.0.5"

resValue "string", "app_name", "Game_YSDK"

}

}

}

repositories {

flatDir {

dirs '../YSDK/libs'

dirs 'libs'

}

}

dependencies {

api fileTree(include: ['*.jar'], dir: 'libs')

testImplementation 'junit:junit:4.12'

androidTestImplementation 'com.android.support.test:runner:1.0.1'

api project(':sdkproxy')

commonApi project(':commonSDK')

ysdkApi project(':YSDK')

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值