plugins { id 'com.android.application' id 'kotlin-android' id 'kotlin-kapt' id 'androidx.navigation.safeargs.kotlin' } android { compileSdkVersion 29 buildToolsVersion "29.0.3" def currentVersionCode = getVersionCode() defaultConfig { applicationId "com.bearya.kids" minSdkVersion 21 targetSdkVersion 29 versionCode currentVersionCode multiDexEnabled true vectorDrawables.useSupportLibrary true javaCompileOptions { annotationProcessorOptions { arguments = ["room.schemaLocation" : "$projectDir/schemas".toString(), "room.expandProjection": "true"] } } ndkVersion "21.3.6528147" buildFeatures { dataBinding true } } flavorDimensions "1.3.0" aaptOptions { noCompress "webp" //表示不让aapt压缩的文件后缀 } sourceSets { main { java { srcDirs = ['src/main/java'] } res { srcDirs = ['src/main/res'] } } kids { assets { srcDirs = ['src/kids/assets'] } } child { assets { srcDirs = ['src/child/assets'] } } } productFlavors { kids { versionName "1.3.0" dimension "1.3.0" } child { versionName "1.3.0" dimension "1.3.0" } } signingConfigs { config { keyAlias 'BeiYa' storePassword 'BeiYa123' storeFile file('../bearya_keystore.jks') keyPassword 'BeiYa!@#' } } buildTypes { debug { debuggable true minifyEnabled false buildConfigField "String", "BuglyAppKey", BUGLY_APP_KEY signingConfig signingConfigs.config proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } release { debuggable false minifyEnabled false buildConfigField "String", "BuglyAppKey", BUGLY_APP_KEY signingConfig signingConfigs.config proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } android.applicationVariants.all { variant -> variant.outputs.each { output -> if ("release" == buildType.name) output.outputFileName = "${variant.productFlavors[0].name}_${defaultConfig.versionCode}_v${variant.productFlavors[0].versionName}_release.apk" else output.outputFileName = "${variant.productFlavors[0].name}_v${defaultConfig.versionName}.apk" } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = 1.8 } } // 获取版本号 def getVersionCode() { def versionFile = file('version.properties')// 读取第一步新建的文件 if (versionFile.canRead()) {// 判断文件读取异常 Properties versionProps = new Properties() versionProps.load(new FileInputStream(versionFile)) def versionCode = versionProps['VERSION_CODE'].toInteger()// 读取文件里面的版本号 versionProps['VERSION_CODE'] = (++versionCode).toString() versionProps.store(versionFile.newWriter(), null) return versionCode // 返回自增之后的版本号 } else { throw new Exception("Could not find version.properties!") } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1' implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.core:core-ktx:1.5.0-alpha05' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.viewpager2:viewpager2:1.0.0' implementation 'androidx.paging:paging-runtime-ktx:3.0.0-alpha12' implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-rc01' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-rc01' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-rc01' implementation 'androidx.lifecycle:lifecycle-reactivestreams-ktx:2.3.0-rc01' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2' implementation 'androidx.navigation:navigation-ui-ktx:2.3.2' implementation 'androidx.room:room-runtime:2.3.0-alpha04' implementation 'androidx.room:room-ktx:2.3.0-alpha04' implementation 'androidx.vectordrawable:vectordrawable:1.1.0' implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.tencent.bugly:crashreport:3.3.3' implementation 'com.github.bumptech.glide:glide:4.11.0' implementation 'com.github.SheHuan:NiceImageView:1.0.5' implementation 'jp.wasabeef:glide-transformations:4.0.1' implementation 'com.orhanobut:logger:2.2.0' implementation 'com.kaopiz:kprogresshud:1.2.0' kapt 'com.github.bumptech.glide:compiler:4.11.0' kapt 'androidx.annotation:annotation:1.1.0' kapt 'androidx.room:room-compiler:2.3.0-alpha04' }