[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Target a build variant\n\nIf you have different versions of your app based on different build variants,\ncreate custom [keep rules](/topic/performance/app-optimization/add-keep-rules) for each variant. For example, if you have a free\ntier and a paid tier of your app with different features and dependencies, each\ntier should have its own keep rules.\n\nCreate keep rules\n-----------------\n\nTo create keep rules that are specific to a build variant, add the\n`proguardFiles` property in the corresponding *flavor* block under\n`productFlavors`. For example, the following build script adds the rules file\n`flavor2‑rules.pro` to the `flavor2` product flavor: \n\n### Kotlin\n\n android {\n ...\n buildTypes {\n getByName(\"release\") {\n isMinifyEnabled = true\n proguardFiles(\n getDefaultProguardFile(\"proguard-android-optimize.txt\"),\n \"proguard-rules.pro\"\n )\n }\n }\n flavorDimensions.add(\"version\")\n productFlavors {\n create(\"flavor1\") {\n ...\n }\n create(\"flavor2\") {\n proguardFile(\"flavor2-rules.pro\")\n }\n }\n }\n\n### Groovy\n\n android {\n ...\n buildTypes {\n release {\n minifyEnabled true\n proguardFiles\n getDefaultProguardFile('proguard-android-optimize.txt'),\n 'proguard-rules.pro'\n }\n }\n flavorDimensions \"version\"\n productFlavors {\n flavor1 {\n ...\n }\n flavor2 {\n proguardFile 'flavor2-rules.pro'\n }\n }\n }\n\n| **Note:** The `flavor2` product flavor uses rules from three rules files---`flavor2‑rules.pro`, `proguard‑rules.pro`, and `proguard‑android‑optimize.txt`---because the script applies the rules from the release block.\n\nAdditional resources\n--------------------\n\n- [Customize which resources to keep](/topic/performance/app-optimization/customize-which-resources-to-keep) --- Learn how to add keep rules for resources."]]