build.gradle.kts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import java.io.FileInputStream
  2. import java.util.Properties
  3. plugins {
  4. id("com.android.application")
  5. id("kotlin-android")
  6. // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
  7. id("dev.flutter.flutter-gradle-plugin")
  8. }
  9. val keystorePropertiesFile = rootProject.file("key.properties")
  10. val keystoreProperties = Properties()
  11. if (keystorePropertiesFile.exists()) {
  12. keystoreProperties.load(FileInputStream(keystorePropertiesFile))
  13. }
  14. android {
  15. namespace = "app.xixi.nomo"
  16. compileSdk = flutter.compileSdkVersion
  17. ndkVersion = flutter.ndkVersion
  18. compileOptions {
  19. sourceCompatibility = JavaVersion.VERSION_11
  20. targetCompatibility = JavaVersion.VERSION_11
  21. }
  22. kotlinOptions {
  23. jvmTarget = JavaVersion.VERSION_11.toString()
  24. }
  25. defaultConfig {
  26. // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
  27. applicationId = "app.xixi.nomo"
  28. // You can update the following values to match your application needs.
  29. // For more information, see: https://flutter.dev/to/review-gradle-config.
  30. minSdk = flutter.minSdkVersion
  31. targetSdk = flutter.targetSdkVersion
  32. versionCode = flutter.versionCode
  33. versionName = flutter.versionName
  34. multiDexEnabled = true
  35. manifestPlaceholders.put("CHANNEL", "universal")
  36. ndk {
  37. abiFilters.add("armeabi-v7a")
  38. abiFilters.add("arm64-v8a")
  39. }
  40. }
  41. flavorDimensions += "env"
  42. productFlavors {
  43. create("googleDev") {
  44. dimension = "env"
  45. applicationIdSuffix = ".dev"
  46. resValue("string", "app_name", "NOMO Dev")
  47. manifestPlaceholders["CHANNEL"] = "google"
  48. }
  49. create("universalDev") {
  50. dimension = "env"
  51. applicationIdSuffix = ".dev"
  52. resValue("string", "app_name", "NOMO Dev")
  53. manifestPlaceholders["CHANNEL"] = "universal"
  54. }
  55. create("googleProd") {
  56. dimension = "env"
  57. manifestPlaceholders["CHANNEL"] = "google"
  58. }
  59. create("universalProd") {
  60. dimension = "env"
  61. manifestPlaceholders["CHANNEL"] = "universal"
  62. }
  63. }
  64. sourceSets {
  65. getByName("main") {
  66. jniLibs.srcDirs("libs")
  67. }
  68. }
  69. packaging {
  70. jniLibs {
  71. useLegacyPackaging = true
  72. keepDebugSymbols += "**/*.so"
  73. // 排除 x86 和 x86_64 架构
  74. excludes += setOf(
  75. "lib/x86/**",
  76. "lib/x86_64/**"
  77. )
  78. }
  79. resources {
  80. excludes += ":META-INF/LICENSE"
  81. excludes += ":META-INF/LICENSE.md"
  82. excludes += ":META-INF/NOTICE"
  83. excludes += setOf(
  84. "META-INF/DebugProbesKt.bin",
  85. "lib/x86/*",
  86. "lib/x86_64/*"
  87. )
  88. }
  89. }
  90. signingConfigs {
  91. create("release") {
  92. keyAlias = keystoreProperties["keyAlias"] as String?
  93. keyPassword = keystoreProperties["keyPassword"] as String?
  94. storeFile = keystoreProperties["storeFile"]?.let { file(it) }
  95. storePassword = keystoreProperties["storePassword"] as String?
  96. }
  97. }
  98. buildTypes {
  99. release {
  100. // TODO: Add your own signing config for the release build.
  101. // Signing with the debug keys for now, so `flutter run --release` works.
  102. signingConfig = signingConfigs.getByName("release")
  103. isShrinkResources = false
  104. isMinifyEnabled = false
  105. }
  106. debug {
  107. signingConfig = signingConfigs.getByName("release")
  108. }
  109. }
  110. }
  111. flutter {
  112. source = "../.."
  113. }
  114. dependencies {
  115. // Core Libraries
  116. implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar", "*.jar"))))
  117. implementation("com.google.code.gson:gson:2.13.2")
  118. implementation("androidx.lifecycle:lifecycle-service:2.8.4")
  119. implementation("commons-io:commons-io:2.6")
  120. }