build.gradle 5.7 KB

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