fix(android): gate interceptor on BuildConfig.DEBUG to prevent prod activation#20
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
android/build.gradle: movedNETWORK_TOOLS_ENABLEDout ofdefaultConfig(where it was alwaystrue) and set it explicitly perbuildType—truefordebug,falseforreleaseexample/MainApplication.kt: wrappedsetCustomClientBuilderinif (BuildConfig.DEBUG)as a second line of defenceREADME.md+docs/SETUP_GUIDE.md: updated both Kotlin and Java examples to show theBuildConfig.DEBUGguard that consumers must apply in their ownMainApplicationWhy two layers of protection?
NETWORK_TOOLS_ENABLED = falsein releasebuildTypeNetworkToolsManager.addInterceptor()a no-op in release — the interceptor is never added to the OkHttp chainif (BuildConfig.DEBUG)inMainApplicationsetCustomClientBuilderfrom running at all in production; makes the debug-only intent explicit to anyone reading the codeTest plan
./gradlew assembleDebug): interceptor active, requests captured in the monitor./gradlew assembleRelease):setCustomClientBuilderblock skipped,NETWORK_TOOLS_ENABLED = false, no interceptor in OkHttp chainCloses #14
🤖 Generated with Claude Code