Skip to content

fix(android): gate interceptor on BuildConfig.DEBUG to prevent prod activation#20

Merged
imsankalp merged 1 commit into
mainfrom
fix/production-build-gating
May 20, 2026
Merged

fix(android): gate interceptor on BuildConfig.DEBUG to prevent prod activation#20
imsankalp merged 1 commit into
mainfrom
fix/production-build-gating

Conversation

@imsankalp

Copy link
Copy Markdown
Owner

Summary

  • android/build.gradle: moved NETWORK_TOOLS_ENABLED out of defaultConfig (where it was always true) and set it explicitly per buildTypetrue for debug, false for release
  • example/MainApplication.kt: wrapped setCustomClientBuilder in if (BuildConfig.DEBUG) as a second line of defence
  • README.md + docs/SETUP_GUIDE.md: updated both Kotlin and Java examples to show the BuildConfig.DEBUG guard that consumers must apply in their own MainApplication

Why two layers of protection?

Layer What it does
NETWORK_TOOLS_ENABLED = false in release buildType Makes NetworkToolsManager.addInterceptor() a no-op in release — the interceptor is never added to the OkHttp chain
if (BuildConfig.DEBUG) in MainApplication Prevents setCustomClientBuilder from running at all in production; makes the debug-only intent explicit to anyone reading the code

Test plan

  • Debug build (./gradlew assembleDebug): interceptor active, requests captured in the monitor
  • Release build (./gradlew assembleRelease): setCustomClientBuilder block skipped, NETWORK_TOOLS_ENABLED = false, no interceptor in OkHttp chain

Closes #14

🤖 Generated with Claude Code

…ctivation

NETWORK_TOOLS_ENABLED was hardcoded to true in defaultConfig, meaning the
OkHttp interceptor was added to the client in every build variant including
release. Two-part fix:

1. android/build.gradle: move the flag out of defaultConfig and set it
   explicitly per buildType (true for debug, false for release).

2. example MainApplication.kt: wrap setCustomClientBuilder in a
   BuildConfig.DEBUG guard as a second line of defence, and to make the
   debug-only intent explicit.

README and SETUP_GUIDE updated to show the BuildConfig.DEBUG guard pattern
that consumers must apply in their own MainApplication.

Closes #14

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@imsankalp
imsankalp merged commit 0af55af into main May 20, 2026
6 of 7 checks passed
@imsankalp
imsankalp deleted the fix/production-build-gating branch May 20, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(android): NETWORK_TOOLS_ENABLED is always true — interceptor runs in production builds

1 participant