build.gradle.kts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 = "com.flashlink.vpn"
  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 = "com.flashlink.vpn"
  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", "flashlink Dev")
  47. manifestPlaceholders["CHANNEL"] = "google"
  48. }
  49. create("universalDev") {
  50. dimension = "env"
  51. applicationIdSuffix = ".dev"
  52. resValue("string", "app_name", "flashlink 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. // 排除 x86 和 x86_64 架构
  73. excludes += setOf(
  74. "lib/x86/**",
  75. "lib/x86_64/**"
  76. )
  77. }
  78. resources {
  79. excludes += ":META-INF/LICENSE"
  80. excludes += ":META-INF/LICENSE.md"
  81. excludes += ":META-INF/NOTICE"
  82. excludes += setOf(
  83. "META-INF/DebugProbesKt.bin",
  84. "lib/x86/*",
  85. "lib/x86_64/*"
  86. )
  87. }
  88. }
  89. signingConfigs {
  90. create("release") {
  91. keyAlias = keystoreProperties["keyAlias"] as String?
  92. keyPassword = keystoreProperties["keyPassword"] as String?
  93. storeFile = keystoreProperties["storeFile"]?.let { file(it) }
  94. storePassword = keystoreProperties["storePassword"] as String?
  95. }
  96. }
  97. buildTypes {
  98. release {
  99. if (keystorePropertiesFile.exists()) {
  100. signingConfig = signingConfigs.getByName("release")
  101. } else {
  102. signingConfig = signingConfigs.getByName("debug")
  103. }
  104. isShrinkResources = false
  105. isMinifyEnabled = false
  106. }
  107. debug {
  108. // 使用默认 debug 签名
  109. }
  110. }
  111. }
  112. flutter {
  113. source = "../.."
  114. }
  115. dependencies {
  116. // Core Libraries
  117. implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar", "*.jar"))))
  118. implementation("com.google.code.gson:gson:2.13.2")
  119. implementation("androidx.lifecycle:lifecycle-service:2.8.4")
  120. implementation("commons-io:commons-io:2.6")
  121. }