-
Notifications
You must be signed in to change notification settings - Fork 45
Configure android gradle release build type #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughConfigures Android release signing to load credentials from key.properties, defines a dedicated release signingConfig with V1/V2 signing, and updates the release build type to enable minification, resource shrinking, and ProGuard optimization, switching signing from debug to the new release configuration. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant Gradle as Gradle (Android)
participant FS as File System
participant Props as keystoreProperties
participant SC as signingConfigs.release
participant BT as buildTypes.release
Dev->>Gradle: assembleRelease
Gradle->>FS: Check key.properties
alt key.properties exists
FS-->>Gradle: Provide file
Gradle->>Props: Load Properties
else
Gradle-->>Props: Initialize empty Properties
end
Gradle->>SC: Configure V1/V2 + storeFile/password + keyAlias/password from Props
Gradle->>BT: Enable minify, shrinkResources, ProGuard optimize + rules
Gradle->>BT: Set signingConfig = SC
Gradle-->>Dev: Build signed, optimized release APK/AAB
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
android/app/build.gradle.kts (2)
11-16: Close the stream when loading key.properties (avoid leak) and simplify.Use inputStream().use { … } to auto-close; drops the need for FileInputStream import.
Apply this diff:
-val keystoreProperties = Properties().apply { - if (keystorePropertiesFile.exists()) { - load(FileInputStream(keystorePropertiesFile)) - } -} +val keystoreProperties = Properties().apply { + if (keystorePropertiesFile.exists()) { + keystorePropertiesFile.inputStream().use { load(it) } + } +}
1-2: Remove now-unneeded import.Apply this diff if you switch to inputStream().use:
import java.util.Properties -import java.io.FileInputStream
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
android/app/build.gradle.kts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: App
- GitHub Check: Flutter Integration Tests (31)
🔇 Additional comments (1)
android/app/build.gradle.kts (1)
86-91: Minify + shrink resources: run a prodRelease sanity check.proguard-rules.pro present (android/app/proguard-rules.pro); key.properties is not committed and is listed in android/.gitignore — run a prodRelease build and quick smoke tests (cold start + main flows) to confirm R8/resource shrinking didn't strip required classes/resources.
| signingConfigs { | ||
| register("release") { | ||
| enableV1Signing = true | ||
| enableV2Signing = true | ||
|
|
||
| storeFile = keystoreProperties["storeFile"]?.let { file(it) } | ||
| storePassword = keystoreProperties["storePassword"] as String? | ||
| keyAlias = keystoreProperties["keyAlias"] as String? | ||
| keyPassword = keystoreProperties["keyPassword"] as String? | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use create(...) instead of register(...) for signingConfigs; add v3/v4 signing; tighten property reads.
register may not be supported on this container and can fail to configure the signing config. Also enable V3/V4 signing and use getProperty for typed reads.
Apply this diff:
- signingConfigs {
- register("release") {
- enableV1Signing = true
- enableV2Signing = true
-
- storeFile = keystoreProperties["storeFile"]?.let { file(it) }
- storePassword = keystoreProperties["storePassword"] as String?
- keyAlias = keystoreProperties["keyAlias"] as String?
- keyPassword = keystoreProperties["keyPassword"] as String?
- }
- }
+ signingConfigs {
+ create("release") {
+ enableV1Signing = true
+ enableV2Signing = true
+ enableV3Signing = true
+ enableV4Signing = true
+
+ keystoreProperties.getProperty("storeFile")?.let { storeFile = file(it) }
+ storePassword = keystoreProperties.getProperty("storePassword")
+ keyAlias = keystoreProperties.getProperty("keyAlias")
+ keyPassword = keystoreProperties.getProperty("keyPassword")
+ }
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| signingConfigs { | |
| register("release") { | |
| enableV1Signing = true | |
| enableV2Signing = true | |
| storeFile = keystoreProperties["storeFile"]?.let { file(it) } | |
| storePassword = keystoreProperties["storePassword"] as String? | |
| keyAlias = keystoreProperties["keyAlias"] as String? | |
| keyPassword = keystoreProperties["keyPassword"] as String? | |
| } | |
| } | |
| signingConfigs { | |
| create("release") { | |
| enableV1Signing = true | |
| enableV2Signing = true | |
| enableV3Signing = true | |
| enableV4Signing = true | |
| keystoreProperties.getProperty("storeFile")?.let { storeFile = file(it) } | |
| storePassword = keystoreProperties.getProperty("storePassword") | |
| keyAlias = keystoreProperties.getProperty("keyAlias") | |
| keyPassword = keystoreProperties.getProperty("keyPassword") | |
| } | |
| } |
🤖 Prompt for AI Agents
In android/app/build.gradle.kts around lines 72-82, replace
signingConfigs.register("release") with signingConfigs.create("release"), enable
V3/V4 signing by setting enableV3Signing = true and enableV4Signing = true, and
tighten property reads by using
keystoreProperties.getProperty("storeFile")/getProperty("storePassword")/getProperty("keyAlias")/getProperty("keyPassword")
(and only call file(...) if storeFile is non-null), so typed property access is
used instead of unchecked casts and the signing config is created with V1–V4
signing enabled.
| isMinifyEnabled = true | ||
| isShrinkResources = true | ||
| proguardFiles( | ||
| getDefaultProguardFile("proguard-android-optimize.txt"), | ||
| "proguard-rules.pro" | ||
| ) | ||
| signingConfig = signingConfigs.getByName("release") | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don’t hard-fail local release builds when key.properties is absent; gate signing or scope it to prod flavor.
As-is, devRelease/qaRelease will require real signing keys. Prefer a conditional fallback to debug signing locally (or assign release signing only to prod flavor).
Option A (inline fallback):
- signingConfig = signingConfigs.getByName("release")
+ signingConfig = if (keystorePropertiesFile.exists())
+ signingConfigs.getByName("release")
+ else
+ signingConfigs.getByName("debug")Option B (scope to prod flavor):
- buildTypes {
- release {
+ buildTypes {
+ release {
...
- signingConfig = signingConfigs.getByName("release")
+ }
+ }
+ productFlavors {
+ // existing dev/qa/prod...
+ getByName("prod") {
+ signingConfig = signingConfigs.getByName("release")
}
}Also verify that proguard-rules.pro exists and includes any Flutter/reflective keep rules to avoid runtime crashes after minification.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| isMinifyEnabled = true | |
| isShrinkResources = true | |
| proguardFiles( | |
| getDefaultProguardFile("proguard-android-optimize.txt"), | |
| "proguard-rules.pro" | |
| ) | |
| signingConfig = signingConfigs.getByName("release") | |
| } | |
| isMinifyEnabled = true | |
| isShrinkResources = true | |
| proguardFiles( | |
| getDefaultProguardFile("proguard-android-optimize.txt"), | |
| "proguard-rules.pro" | |
| ) | |
| signingConfig = if (keystorePropertiesFile.exists()) | |
| signingConfigs.getByName("release") | |
| else | |
| signingConfigs.getByName("debug") | |
| } |
🤖 Prompt for AI Agents
In android/app/build.gradle.kts around lines 86 to 93, the release build
currently hard-fails when signing keys (key.properties) are missing causing
devRelease/qaRelease to require production keys; change the config to either (A)
conditionally apply the release signingConfig only when key.properties is
present (fall back to debug signing for local/dev builds) or (B) move/assign the
release signingConfig only to the prod flavor block so dev/qa builds use debug
signing, and ensure the signingConfig lookup is guarded to avoid exceptions;
additionally verify proguard-rules.pro exists in the project and include
necessary Flutter/reflective -keep rules to prevent runtime crashes after
minification.
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #46 +/- ##
=======================================
Coverage 83.80% 83.80%
=======================================
Files 118 118
Lines 2451 2451
=======================================
Hits 2054 2054
Misses 397 397 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit