build.gradle.kts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. plugins {
  2. id("com.android.application")
  3. id("kotlin-android")
  4. // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
  5. id("dev.flutter.flutter-gradle-plugin")
  6. }
  7. android {
  8. namespace = "com.trace.location"
  9. compileSdk = rootProject.extra["compileSdkVersion"] as Int
  10. ndkVersion = rootProject.extra["ndkVersion"] as String
  11. compileOptions {
  12. sourceCompatibility = JavaVersion.VERSION_11
  13. targetCompatibility = JavaVersion.VERSION_11
  14. }
  15. kotlinOptions {
  16. jvmTarget = JavaVersion.VERSION_11.toString()
  17. }
  18. defaultConfig {
  19. // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
  20. applicationId = rootProject.extra["applicationId"] as String
  21. // You can update the following values to match your application needs.
  22. // For more information, see: https://flutter.dev/to/review-gradle-config.
  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. //noinspection ChromeOsAbiSupport
  29. abiFilters.add("arm64-v8a")
  30. }
  31. }
  32. signingConfigs {
  33. create("location") {
  34. storeFile = file("keystore/location.jks")
  35. storePassword = "location888"
  36. keyAlias = "location"
  37. keyPassword = "location888"
  38. }
  39. }
  40. android {
  41. buildTypes {
  42. getByName("debug") {
  43. // Note: The debug build type must have the same signing config as the main build type.
  44. signingConfig = signingConfigs.getByName("location")
  45. }
  46. getByName("release") {
  47. // TODO: Add your own signing config for the release build.
  48. // Signing with the debug keys for now, so `flutter run --release` works.
  49. isMinifyEnabled = true
  50. proguardFiles(
  51. getDefaultProguardFile("proguard-android-optimize.txt"),
  52. "proguard-rules.pro"
  53. )
  54. signingConfig = signingConfigs.getByName("location")
  55. }
  56. }
  57. }
  58. // applicationVariants.all { variant ->
  59. // val date = java.text.SimpleDateFormat("yyMMddHHmmss").format(Date()) // 改用 SimpleDateFormat
  60. // variant.outputs.configureEach { // 使用 configureEach 替代 all
  61. // val fileName = "${defaultConfig.applicationId}-" +
  62. // "v${defaultConfig.versionName}-" +
  63. // "${variant.buildType.name}-" +
  64. // "${date}.apk"
  65. // this as com.android.build.gradle.internal.api.BaseVariantOutputImpl // 强制类型转换
  66. // outputFileName.set(fileName) // 正确设置文件名
  67. // }
  68. // }
  69. }
  70. flutter {
  71. source = "../.."
  72. }