build.gradle.kts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. // ✅ 建议加上这一行,确保 5 个广告 SDK 不会撑破方法数限制
  40. multiDexEnabled = true
  41. }
  42. signingConfigs {
  43. create("release") { // 使用 create 方法来定义签名配置
  44. storeFile = file(localProperties.getProperty("storeFile"))
  45. storePassword = localProperties.getProperty("storePassword")
  46. keyAlias = localProperties.getProperty("keyAlias")
  47. keyPassword = localProperties.getProperty("keyPassword")
  48. }
  49. }
  50. buildTypes {
  51. release {
  52. // ✅ 启用 R8 代码混淆和收缩(Kotlin DSL: 使用 isMinifyEnabled = true)
  53. isMinifyEnabled = true
  54. // ✅ 启用资源收缩(Kotlin DSL: 使用 isShrinkResources = true)
  55. isShrinkResources = true
  56. // ✅ 指定 ProGuard 规则文件(Kotlin DSL: 使用 proguardFiles(...) 函数)
  57. proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
  58. // TODO: Add your own signing config for the release build.
  59. // Signing with the debug keys for now, so `flutter run --release` works.
  60. // signingConfig = signingConfigs.getByName("debug")
  61. signingConfig = signingConfigs.getByName("release")
  62. }
  63. }
  64. }
  65. flutter {
  66. source = "../.."
  67. }
  68. dependencies {
  69. // ✅ MultiDex 支持库
  70. implementation("androidx.multidex:multidex:2.0.1")
  71. // AppLovin MAX 核心适配器 (建议使用最新版本或与你的 AppLovin SDK 匹配的版本)
  72. // 注意:Kotlin DSL 使用 implementation("...") 括号加双引号
  73. // 1. AdMob (Google) 适配器
  74. implementation("com.applovin.mediation:google-adapter:23.3.0.0")
  75. // 2. Meta (Facebook) 适配器
  76. implementation("com.applovin.mediation:facebook-adapter:6.17.0.0")
  77. // 3. UnityAds
  78. implementation("com.applovin.mediation:unityads-adapter:4.12.2.0")
  79. // 4. Moloco
  80. implementation("com.applovin.mediation:moloco-adapter:3.0.0.0")
  81. // 5. Mintegral
  82. implementation("com.applovin.mediation:mintegral-adapter:16.8.51.0")
  83. }