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

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')

}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,015评论 25 709
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,993评论 6 342
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,107评论 19 139
  • 这一章主要针对项目中可以用到的一些实用功能来介绍Android Gradle,比如如何隐藏我们的证书文件,降低风险...
    acc8226阅读 7,735评论 3 25
  • 【第二章】 傍晚,濑名泉戴着帽子和口罩,坐在广场的长椅上,身侧摆着一袋子碳酸饮料。 不知道他什么口味,就一样买了一...
    大魔法家阅读 2,577评论 0 4