build.gradle 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. apply plugin: 'com.android.application'
  2. def getVersionCode() {// 获取版本号
  3. def versionFile = file('version.properties')// 读取第一步新建的文件
  4. if (versionFile.canRead()) {// 判断文件读取异常
  5. Properties versionProps = new Properties()
  6. versionProps.load(new FileInputStream(versionFile))
  7. def versionCode = versionProps['VERSION_CODE'].toInteger()// 读取文件里面的版本号
  8. def runTasks = gradle.startParameter.taskNames
  9. // if ('assembleRelease' in runTasks) {//仅在assembleRelease任务是增加版本号,其他渠道包在此分别配置
  10. if ('assemble' in runTasks) {
  11. // 版本号自增之后再写入文件(此处是关键,版本号自增+1)
  12. versionProps['VERSION_CODE'] = (++versionCode).toString()
  13. versionProps.store(versionFile.newWriter(), null)
  14. }
  15. return versionCode // 返回自增之后的版本号
  16. } else {
  17. throw new GradleException("Could not find version.properties!")
  18. }
  19. }
  20. def getVersionName() {// 获取版本号
  21. def versionFile = file('version.properties')// 读取第一步新建的文件
  22. if (versionFile.canRead()) {// 判断文件读取异常
  23. Properties versionProps = new Properties()
  24. versionProps.load(new FileInputStream(versionFile))
  25. def versionName = versionProps['VERSION_NAME'].toString()// 读取文件里面的版本号
  26. return versionName // 返回自增之后的版本号
  27. } else {
  28. throw new GradleException("Could not find version.properties!")
  29. }
  30. }
  31. android {
  32. compileSdkVersion 30
  33. def defaultVersionName = getVersionName()
  34. def defaultVersionCode = getVersionCode()
  35. defaultConfig {
  36. applicationId "cn.gxeea.zk"
  37. minSdkVersion 24
  38. //noinspection ExpiredTargetSdkVersion
  39. targetSdkVersion 30
  40. versionCode defaultVersionCode
  41. versionName defaultVersionName
  42. multiDexEnabled true
  43. compileOptions {
  44. sourceCompatibility JavaVersion.VERSION_1_8
  45. targetCompatibility JavaVersion.VERSION_1_8
  46. }
  47. sourceSets {
  48. main {
  49. jniLibs.srcDirs = ['libs', "src/main/jniLibs"]
  50. }
  51. }
  52. ndk {
  53. // abiFilters "armeabi"
  54. abiFilters 'armeabi-v7a','arm64-v8a'
  55. }
  56. }
  57. signingConfigs {
  58. config {
  59. keyAlias 'ses'
  60. keyPassword '123456'
  61. storeFile file('./app.jks')
  62. storePassword '123456'
  63. v1SigningEnabled true
  64. v2SigningEnabled true
  65. }
  66. }
  67. buildTypes {
  68. debug {
  69. signingConfig signingConfigs.config
  70. minifyEnabled false
  71. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  72. }
  73. release {
  74. signingConfig signingConfigs.config
  75. minifyEnabled false
  76. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  77. }
  78. }
  79. packagingOptions {
  80. jniLibs {
  81. keepDebugSymbols += ['*/arm64-v8a/*.so', '*/armeabi-v7a/*.so']
  82. pickFirsts += ['lib/*/libc++_shared.so']
  83. useLegacyPackaging true
  84. }
  85. }
  86. androidResources {
  87. ignoreAssetsPattern '!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~'
  88. additionalParameters '--auto-add-overlay'
  89. }
  90. namespace 'cn.gxeea.zk'
  91. android.applicationVariants.configureEach { variant ->
  92. variant.outputs.all {
  93. outputFileName = "ses-app-" + variant.name + "-" + variant.versionName + "-build(" + variant.versionCode + ")" + getTime() + ".apk"
  94. }
  95. }
  96. }
  97. static def getTime() {
  98. return "-" + new Date().format("yyyyMMddHHmm", TimeZone.getTimeZone("UTC"))
  99. }
  100. //
  101. dependencies {
  102. implementation fileTree(include: ['*.jar'], dir: 'libs')
  103. implementation fileTree(include: ['*.aar'], dir: 'libs')
  104. implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
  105. implementation 'androidx.multidex:multidex:2.0.1'
  106. //
  107. // implementation 'androidx.appcompat:appcompat:1.0.0'
  108. implementation 'androidx.legacy:legacy-support-v4:1.0.0'
  109. // implementation 'androidx.recyclerview:recyclerview:1.0.0'
  110. implementation 'com.facebook.fresco:fresco:2.5.0'
  111. implementation "com.facebook.fresco:animated-gif:2.5.0"
  112. implementation 'com.github.bumptech.glide:glide:4.16.0'
  113. // implementation 'com.github.bumptech.glide:glide:4.9.0'
  114. implementation 'com.alibaba:fastjson:1.1.46.android'
  115. implementation 'com.google.code.gson:gson:2.8.6'
  116. implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.5.8'
  117. // implementation 'androidx.annotation:annotation-jvm:1.7.0'
  118. // implementation fileTree(dir: 'libs', include: ['*.aar'])
  119. implementation 'androidx.appcompat:appcompat:1.3.1'
  120. implementation 'com.google.android.material:material:1.4.0'
  121. implementation 'androidx.recyclerview:recyclerview:1.1.0'
  122. implementation 'androidx.annotation:annotation:1.2.0'
  123. // implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
  124. // testImplementation 'junit:junit:4.13.2'
  125. // androidTestImplementation 'androidx.test.ext:junit:1.1.3'
  126. androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
  127. // implementation fileTree(dir: '../app/libs', include: ['FaceImageLib-1.1.0.aar'])
  128. implementation 'com.squareup.okhttp3:okhttp:4.11.0'
  129. // implementation "com.android.support:support-v4:28.0.0"
  130. // implementation "com.android.support:appcompat-v7:28.0.0"
  131. // implementation 'com.android.support:recyclerview-v7:28.0.0'
  132. // implementation 'com.facebook.fresco:fresco:1.13.0'
  133. // implementation "com.facebook.fresco:animated-gif:1.13.0"
  134. // implementation 'com.github.bumptech.glide:glide:4.9.0'
  135. // implementation 'com.alibaba:fastjson:1.1.46.android'
  136. }