[#570] Add preRelease build type to distribute release build with Chucker#627
Conversation
📝 WalkthroughWalkthroughAdds a new "preRelease" build type and dependency configuration across templates and samples, updates CI to build/deploy preRelease APKs, adjusts ProGuard/consumer rules, changes OkHttp logging gating to BUILD_TYPE-based checks, and applies minor Kotlin style/error-handling tweaks. Changes
Sequence Diagram(s)mermaid CI->>Gradle: trigger assembleStagingPreRelease / assembleProductionPreRelease Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 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.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
template-compose/app/src/main/java/co/nimblehq/template/compose/di/modules/OkHttpClientModule.kt (1)
26-32:⚠️ Potential issue | 🔴 CriticalBug:
readTimeoutis only applied in non-release builds.
readTimeout(READ_TIME_OUT, TimeUnit.SECONDS)is inside theifblock, so release builds will fall back to OkHttp's default 10-second read timeout instead of 30 seconds. This was likely the intended timeout for all build types and should be moved outside the conditional.🐛 Proposed fix
) = OkHttpClient.Builder().apply { if (!BuildConfig.BUILD_TYPE.equals(BUILD_TYPE_RELEASE, ignoreCase = true)) { addInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY }) addInterceptor(chuckerInterceptor) - readTimeout(READ_TIME_OUT, TimeUnit.SECONDS) } + readTimeout(READ_TIME_OUT, TimeUnit.SECONDS) }.build()sample-compose/app/src/main/java/co/nimblehq/sample/compose/di/modules/OkHttpClientModule.kt (1)
25-32:⚠️ Potential issue | 🟠 Major
readTimeoutis only set for non-release builds.
readTimeout(READ_TIME_OUT, ...)on line 31 is inside theifblock, so release builds will use OkHttp's default timeout (10 seconds). If this is intentional, consider adding a comment. If not, move it outside the conditional.Proposed fix (if timeout should apply to all builds)
) = OkHttpClient.Builder().apply { + readTimeout(READ_TIME_OUT, TimeUnit.SECONDS) if (!BuildConfig.BUILD_TYPE.equals(BUILD_TYPE_RELEASE, ignoreCase = true)) { addInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY }) addInterceptor(chuckerInterceptor) - readTimeout(READ_TIME_OUT, TimeUnit.SECONDS) } }.build()
🤖 Fix all issues with AI agents
In
@.cicdtemplate/.github/workflows/deploy_staging_and_production_to_firebase_app_distribution.yml:
- Line 68: Replace the incorrect APK filenames used in the workflow: change the
occurrences of "app-staging-debug.apk" to "app-staging-preRelease.apk" and
"app-production-debug.apk" to "app-production-preRelease.apk" so the Firebase
distribution step points to the actual build outputs (ensure you update both
references that currently use the "-debug.apk" names).
In `@template-compose/app/build.gradle.kts`:
- Line 1: Remove the unused import of JvmTarget at the top of the file; locate
the import statement referencing JvmTarget and delete it so the file no longer
imports JvmTarget (kotlinOptions already uses
JavaVersion.VERSION_17.toString()), ensuring no other code references JvmTarget
remain.
In `@template-compose/buildSrc/src/main/java/DependencyHandlerExt.kt`:
- Around line 1-5: Add the missing extension in the sample project's buildSrc:
create a DependencyHandlerExt.kt that defines fun
DependencyHandler.preReleaseImplementation(dependencyNotation: Any): Dependency?
= add("preReleaseImplementation", dependencyNotation) so the call to
preReleaseImplementation resolves; reference the existing symbol name
preReleaseImplementation and the receiver type DependencyHandler when adding the
file.
In `@template-compose/data/consumer-rules.pro`:
- Around line 34-36: The comment about Chucker/Gson proguard rules is dangling —
either add the actual keep/dontwarn rules referenced or remove the comment; to
fix, update the consumer-rules.pro by appending the recommended Chucker/Gson
rules (e.g., keep rules for Chucker UI classes and Gson TypeAdapter/reflective
access rules and appropriate -dontwarn entries as in the Chucker issue and Gson
proguard example) or delete the three-line comment block entirely so there are
no misleading references to missing proguard rules; look for the "Chucker" and
"Gson" mentions in the file to place or remove the rules.
- Line 22: Fix the typo in the comment string "NewRelic instrucmentation" by
changing "instrucmentation" to "instrumentation" to read "NewRelic
instrumentation"; update the comment where that text appears (the line
containing the NewRelic comment) so documentation/readme strings are correct.
- Around line 31-32: The ProGuard keep rules currently reference the wrong
package (com.jfc.template.core.network.*); update the two keep entries so they
point to the real model packages (e.g.
co.nimblehq.template.compose.data.network.request.** { *; } and
co.nimblehq.template.compose.data.network.response.** { *; }) so your
request/response model classes are preserved; replace the existing lines
referencing com.jfc.template.core.network.request/response with the corrected
co.nimblehq... package names in the same keep rule format.
🧹 Nitpick comments (6)
sample-compose/app/src/main/java/co/nimblehq/sample/compose/di/modules/OkHttpClientModule.kt (1)
16-16: Consider reusing theBuildTypes.RELEASEconstant instead of a hardcoded string.The
"release"value is already defined asBuildType.RELEASEinConfigurations.kt. While buildSrc constants aren't directly accessible at runtime, you could referenceBuildTypes.RELEASEif it were made available, or at minimum add a comment noting the coupling. This avoids silent breakage if the release build type name ever changes.template-compose/app/build.gradle.kts (1)
67-69: Consider whetherisDebuggable = falseis intended for preRelease.Since
preReleaseisinitWith(release), it inheritsisDebuggable = false,isMinifyEnabled = true, andisShrinkResources = true. This means the preRelease APK distributed to testers will behave almost identically to the release build (just with Chucker added). If the intent is to give testers a debuggable build with Chucker, you may want to overrideisDebuggable = true. If the current behavior is intentional (near-release fidelity), a brief comment would help clarify.template-compose/data/consumer-rules.pro (1)
8-11: Redundant keep rules —retrofit2.**already coversretrofit2.Retrofit.Line 8 keeps all classes in
retrofit2.**, making the specific keep on line 11 redundant. Similarly, line 24 (okhttp3.**) makes line 28 (okhttp3.Headers) redundant.template-compose/data/build.gradle.kts (2)
1-1: Unused import:JvmTargetis not referenced anywhere in this file.
kotlinOptionson line 40 usesJavaVersion.VERSION_17.toString(), notJvmTarget.-import org.jetbrains.kotlin.gradle.dsl.JvmTarget - plugins {
16-22:consumerProguardFiles("consumer-rules.pro")is declared in bothdefaultConfig(line 16) and thereleaseblock (line 22).The
defaultConfigdeclaration already applies to all build types. The duplicate in thereleaseblock will cause the consumer rules to be applied twice during release builds. Remove one of them — typically keeping only thedefaultConfigone is sufficient.Proposed fix
buildTypes { release { isMinifyEnabled = false - consumerProguardFiles("consumer-rules.pro") }sample-compose/data/build.gradle.kts (1)
13-19: Same duplication:consumerProguardFilesin bothdefaultConfigandrelease.Same issue as in
template-compose/data/build.gradle.kts— thedefaultConfigdeclaration (line 13) already applies to all variants.Proposed fix
getByName(BuildType.RELEASE) { isMinifyEnabled = false - consumerProguardFiles("consumer-rules.pro") }
.cicdtemplate/.github/workflows/deploy_staging_and_production_to_firebase_app_distribution.yml
Outdated
Show resolved
Hide resolved
Kover report for template-compose:🧛 Template - Compose Unit Tests Code Coverage:
|
| File | Coverage |
|---|---|
RepositoryImpl.kt |
100.00% |
ResponseMapping.kt |
95.00% |
Modified Files Not Found In Coverage Report:
BuildTypes.kt
Configurations.kt
DependencyHandlerExt.kt
DependencyHandlerExt.kt
OkHttpClientModule.kt
OkHttpClientModule.kt
build.gradle.kts
build.gradle.kts
build.gradle.kts
build.gradle.kts
consumer-rules.pro
consumer-rules.pro
deploy_staging_and_production_to_firebase_app_distribution.yml
proguard-rules.pro
proguard-rules.pro
proguard-rules.pro
proguard-rules.pro
Codebase cunningly covered by count Shroud 🧛
Generated by 🚫 Danger
732cf9d to
fcd7e54
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@sample-compose/data/consumer-rules.pro`:
- Line 22: Typo in the comment "# Keep classes for NewRelic instrucmentation":
change "instrucmentation" to "instrumentation" so the line reads "# Keep classes
for NewRelic instrumentation"; update that exact comment string in
sample-compose/data/consumer-rules.pro.
- Line 30: Update the broken URL in the comment string
"https://medium0.com/androiddevelopers/practical-proguard-rules-examples-5640a3907dc9"
to the correct host (replace medium0.com with medium.com) so the comment reads
"https://medium.com/androiddevelopers/practical-proguard-rules-examples-5640a3907dc9".
- Around line 34-36: Add the missing ProGuard rules for Chucker and Gson by
adding the appropriate -keep and -dontwarn entries referenced in the Gson
example and Chucker issue: include -keep rules for Chucker
model/collector/okhttp classes (e.g., classes under
com.github.chuckerteam.chucker.**), and add -keep for Gson reflective model
usage (e.g., com.google.gson.** and model classes serialized/deserialized via
Gson) plus any necessary -dontwarn entries for Gson and Chucker to silence
unused-annotation/okhttp warnings; place these rules in the
sample-compose/data/consumer-rules.pro where the Chucker/Gson comment block
currently exists so the preRelease build preserves the required classes and
avoids the Chucker log-item click crash.
🧹 Nitpick comments (1)
sample-compose/data/consumer-rules.pro (1)
8-12: Redundant keep rules due to broad wildcard on line 8.
-keep class retrofit2.** { *; }already coversretrofit2.Retrofit, making line 11 redundant. Similarly,-keep class okhttp3.** { *; }on line 24 will coverokhttp3.HttpUrl(line 12) andokhttp3.Headers(line 28).Consider removing the specific per-class rules that are already subsumed by the broad wildcard keeps, or if the intent is to document why each class is kept, convert the narrower rules to comments.
fcd7e54 to
001c336
Compare
#570
What happened 👀
template-composeandsample-composeInsight 📝
I updated to disable minifying and proguard rules on modules, switching to use
consumer-prorules and enable minify in :app module to avoid build failed due to the code is obfuscated before building the :app moduleProof Of Work 📹
Screen.Recording.2026-02-09.at.17.46.44.mov
Summary by CodeRabbit
New Features
Chores