build.gradle 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. plugins {
  2. id 'com.android.application'
  3. id 'kotlin-android'
  4. id 'kotlin-kapt'
  5. id 'androidx.navigation.safeargs.kotlin'
  6. }
  7. android {
  8. compileSdkVersion 29
  9. buildToolsVersion "29.0.3"
  10. def currentVersionCode = getVersionCode()
  11. defaultConfig {
  12. applicationId "com.bearya.kids"
  13. minSdkVersion 21
  14. targetSdkVersion 29
  15. versionCode currentVersionCode
  16. multiDexEnabled true
  17. vectorDrawables.useSupportLibrary true
  18. javaCompileOptions {
  19. annotationProcessorOptions {
  20. arguments = ["room.schemaLocation" : "$projectDir/schemas".toString(),
  21. "room.expandProjection": "true"]
  22. }
  23. }
  24. ndkVersion "21.3.6528147"
  25. buildFeatures {
  26. dataBinding true
  27. }
  28. }
  29. flavorDimensions "1.3.0"
  30. aaptOptions {
  31. noCompress "webp" //表示不让aapt压缩的文件后缀
  32. }
  33. sourceSets {
  34. main {
  35. java {
  36. srcDirs = ['src/main/java']
  37. }
  38. res {
  39. srcDirs = ['src/main/res']
  40. }
  41. }
  42. kids {
  43. assets {
  44. srcDirs = ['src/kids/assets']
  45. }
  46. }
  47. child {
  48. assets {
  49. srcDirs = ['src/child/assets']
  50. }
  51. }
  52. }
  53. productFlavors {
  54. kids {
  55. versionName "1.3.0"
  56. dimension "1.3.0"
  57. }
  58. child {
  59. versionName "1.3.0"
  60. dimension "1.3.0"
  61. }
  62. }
  63. signingConfigs {
  64. config {
  65. keyAlias 'BeiYa'
  66. storePassword 'BeiYa123'
  67. storeFile file('../bearya_keystore.jks')
  68. keyPassword 'BeiYa!@#'
  69. }
  70. }
  71. buildTypes {
  72. debug {
  73. debuggable true
  74. minifyEnabled false
  75. buildConfigField "String", "BuglyAppKey", BUGLY_APP_KEY
  76. signingConfig signingConfigs.config
  77. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  78. }
  79. release {
  80. debuggable false
  81. minifyEnabled false
  82. buildConfigField "String", "BuglyAppKey", BUGLY_APP_KEY
  83. signingConfig signingConfigs.config
  84. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  85. }
  86. }
  87. android.applicationVariants.all { variant ->
  88. variant.outputs.each { output ->
  89. if ("release" == buildType.name)
  90. output.outputFileName = "${variant.productFlavors[0].name}_${defaultConfig.versionCode}_v${variant.productFlavors[0].versionName}_release.apk"
  91. else
  92. output.outputFileName = "${variant.productFlavors[0].name}_v${defaultConfig.versionName}.apk"
  93. }
  94. }
  95. compileOptions {
  96. sourceCompatibility JavaVersion.VERSION_1_8
  97. targetCompatibility JavaVersion.VERSION_1_8
  98. }
  99. kotlinOptions {
  100. jvmTarget = 1.8
  101. }
  102. }
  103. // 获取版本号
  104. def getVersionCode() {
  105. def versionFile = file('version.properties')// 读取第一步新建的文件
  106. if (versionFile.canRead()) {// 判断文件读取异常
  107. Properties versionProps = new Properties()
  108. versionProps.load(new FileInputStream(versionFile))
  109. def versionCode = versionProps['VERSION_CODE'].toInteger()// 读取文件里面的版本号
  110. versionProps['VERSION_CODE'] = (++versionCode).toString()
  111. versionProps.store(versionFile.newWriter(), null)
  112. return versionCode // 返回自增之后的版本号
  113. } else {
  114. throw new Exception("Could not find version.properties!")
  115. }
  116. }
  117. dependencies {
  118. implementation fileTree(dir: 'libs', include: ['*.jar'])
  119. implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  120. implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
  121. implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
  122. implementation 'androidx.appcompat:appcompat:1.2.0'
  123. implementation 'androidx.core:core-ktx:1.5.0-alpha05'
  124. implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
  125. implementation 'androidx.viewpager2:viewpager2:1.0.0'
  126. implementation 'androidx.paging:paging-runtime-ktx:3.0.0-alpha12'
  127. implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-rc01'
  128. implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-rc01'
  129. implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-rc01'
  130. implementation 'androidx.lifecycle:lifecycle-reactivestreams-ktx:2.3.0-rc01'
  131. implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2'
  132. implementation 'androidx.navigation:navigation-ui-ktx:2.3.2'
  133. implementation 'androidx.room:room-runtime:2.3.0-alpha04'
  134. implementation 'androidx.room:room-ktx:2.3.0-alpha04'
  135. implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
  136. implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
  137. implementation 'androidx.cardview:cardview:1.0.0'
  138. implementation 'androidx.recyclerview:recyclerview:1.1.0'
  139. implementation 'androidx.multidex:multidex:2.0.1'
  140. implementation 'com.google.code.gson:gson:2.8.6'
  141. implementation 'com.tencent.bugly:crashreport:3.3.3'
  142. implementation 'com.github.bumptech.glide:glide:4.11.0'
  143. implementation 'com.github.SheHuan:NiceImageView:1.0.5'
  144. implementation 'jp.wasabeef:glide-transformations:4.0.1'
  145. implementation 'com.orhanobut:logger:2.2.0'
  146. implementation 'com.kaopiz:kprogresshud:1.2.0'
  147. kapt 'com.github.bumptech.glide:compiler:4.11.0'
  148. kapt 'androidx.annotation:annotation:1.1.0'
  149. kapt 'androidx.room:room-compiler:2.3.0-alpha04'
  150. }