common.gradle 1.67 KB
// 通用配置
android {

    // 编译源码版本
    compileSdkVersion 30
    buildToolsVersion "29.0.2"

    defaultConfig {
        // 最低安装版本
        minSdkVersion 24
        // 目标适配版本
        targetSdkVersion 28
        versionName '2.0.7'
        versionCode 207
    }

    // 支持 Java JDK 8
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }

    // 设置存放 so 文件的目录
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    // 可在 Studio 最左侧中的 Build Variants 选项中切换默认的构建类型
    buildTypes {
        // 调试版本
        debug {}
        // 预览版本
        preview {}
        // 正式版本
        release {}
    }

    // 代码警告配置
    lintOptions {
        // 禁用文本硬编码警告
        disable 'HardcodedText'
        // 禁用图片描述警告
        disable 'ContentDescription'
    }
}

afterEvaluate {
    // 前提条件是这个 Module 工程必须是 Library 类型,并且排除名为 umeng 的 Module 工程
    if (android.defaultConfig.applicationId == null && "umeng" != getName()) {
        // 排除 BuildConfig.class
        generateReleaseBuildConfig.enabled = false
        generatePreviewBuildConfig.enabled = false
        generateDebugBuildConfig.enabled = false
    }
}

dependencies {


    // AndroidX 库:https://github.com/androidx/androidx
    implementation 'androidx.appcompat:appcompat:1.3.1'
    // Material 库:https://github.com/material-components/material-components-android
    implementation 'com.google.android.material:material:1.4.0'
}