build.gradle.kts 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import java.time.LocalDateTime
  2. import java.time.format.DateTimeFormatter
  3. import java.time.ZoneId
  4. plugins {
  5. id("com.android.application")
  6. id("kotlin-android")
  7. // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
  8. id("dev.flutter.flutter-gradle-plugin")
  9. }
  10. android {
  11. namespace = "com.atmob.keyboard"
  12. compileSdk = rootProject.extra["compileSdkVersion"] as Int
  13. ndkVersion = rootProject.extra["ndkVersion"] as String
  14. compileOptions {
  15. sourceCompatibility = JavaVersion.VERSION_11
  16. targetCompatibility = JavaVersion.VERSION_11
  17. }
  18. kotlinOptions {
  19. jvmTarget = JavaVersion.VERSION_11.toString()
  20. }
  21. defaultConfig {
  22. applicationId = rootProject.extra["applicationId"] as String
  23. minSdk = rootProject.extra["minSdkVersion"] as Int
  24. targetSdk = rootProject.extra["targetSdkVersion"] as Int
  25. versionCode = flutter.versionCode
  26. versionName = flutter.versionName
  27. ndk {
  28. abiFilters.add("arm64-v8a")
  29. }
  30. }
  31. signingConfigs {
  32. create("keyboard") {
  33. storeFile = file("keystore/zhuiai.jks")
  34. storePassword = "zhuiai888"
  35. keyAlias = "zhuiai"
  36. keyPassword = "zhuiai888"
  37. }
  38. }
  39. buildTypes {
  40. getByName("debug") {
  41. // 允许debug
  42. isDebuggable = true
  43. // 是否开启混淆
  44. // isMinifyEnabled = true
  45. // proguardFiles(
  46. // getDefaultProguardFile("proguard-android-optimize.txt"),
  47. // "proguard-rules.pro"
  48. // )
  49. // Note: The debug build type must have the same signing config as the main build type.
  50. signingConfig = signingConfigs.getByName("keyboard")
  51. }
  52. getByName("release") {
  53. // TODO: Add your own signing config for the release build.
  54. // Signing with the debug keys for now, so `flutter run --release` works.
  55. isMinifyEnabled = true
  56. proguardFiles(
  57. getDefaultProguardFile("proguard-android-optimize.txt"),
  58. "proguard-rules.pro"
  59. )
  60. signingConfig = signingConfigs.getByName("keyboard")
  61. }
  62. }
  63. applicationVariants.all {
  64. val variant = this
  65. variant.outputs.map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl }
  66. .forEach { output ->
  67. val formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmm")
  68. val date = LocalDateTime.now(ZoneId.of("Asia/Shanghai")).format(formatter)
  69. val outputFileName =
  70. "${variant.applicationId}-v${variant.versionName}-${variant.baseName}-${date}.apk"
  71. output.outputFileName = outputFileName
  72. }
  73. }
  74. }
  75. flutter {
  76. source = "../.."
  77. }