build.gradle.kts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import java.util.Properties
  2. val localPropertiesFile = rootProject.file("key.properties")
  3. val localProperties = Properties()
  4. if (localPropertiesFile.exists()) {
  5. localPropertiesFile.inputStream().use { inputStream ->
  6. localProperties.load(inputStream)
  7. }
  8. }
  9. plugins {
  10. id("com.android.application")
  11. id("kotlin-android")
  12. // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
  13. id("dev.flutter.flutter-gradle-plugin")
  14. id("com.google.gms.google-services")
  15. }
  16. android {
  17. namespace = "jigsort.solitaire.jigsaw.match.games"
  18. // compileSdk = flutter.compileSdkVersion
  19. // ndkVersion = flutter.ndkVersion
  20. compileSdk = 36
  21. ndkVersion = "27.0.12077973"
  22. compileOptions {
  23. sourceCompatibility = JavaVersion.VERSION_11
  24. targetCompatibility = JavaVersion.VERSION_11
  25. }
  26. kotlinOptions {
  27. jvmTarget = JavaVersion.VERSION_11.toString()
  28. }
  29. defaultConfig {
  30. // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
  31. applicationId = "jigsort.solitaire.jigsaw.match.games"
  32. // You can update the following values to match your application needs.
  33. // For more information, see: https://flutter.dev/to/review-gradle-config.
  34. // minSdk = flutter.minSdkVersion
  35. minSdk = 23
  36. targetSdk = flutter.targetSdkVersion
  37. versionCode = flutter.versionCode
  38. versionName = flutter.versionName
  39. }
  40. signingConfigs {
  41. create("release") { // 使用 create 方法来定义签名配置
  42. storeFile = file(localProperties.getProperty("storeFile"))
  43. storePassword = localProperties.getProperty("storePassword")
  44. keyAlias = localProperties.getProperty("keyAlias")
  45. keyPassword = localProperties.getProperty("keyPassword")
  46. }
  47. }
  48. buildTypes {
  49. release {
  50. // ✅ 启用 R8 代码混淆和收缩(Kotlin DSL: 使用 isMinifyEnabled = true)
  51. isMinifyEnabled = true
  52. // ✅ 启用资源收缩(Kotlin DSL: 使用 isShrinkResources = true)
  53. isShrinkResources = true
  54. // ✅ 指定 ProGuard 规则文件(Kotlin DSL: 使用 proguardFiles(...) 函数)
  55. proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
  56. // TODO: Add your own signing config for the release build.
  57. // Signing with the debug keys for now, so `flutter run --release` works.
  58. // signingConfig = signingConfigs.getByName("debug")
  59. signingConfig = signingConfigs.getByName("release")
  60. }
  61. }
  62. }
  63. flutter {
  64. source = "../.."
  65. }