Skip to content

Fix Android release builds using Test ConfigCat SDK key instead of Production#105

Closed
Copilot wants to merge 3 commits intorelease/1.2.0from
copilot/sub-pr-102
Closed

Fix Android release builds using Test ConfigCat SDK key instead of Production#105
Copilot wants to merge 3 commits intorelease/1.2.0from
copilot/sub-pr-102

Conversation

Copy link
Contributor

Copilot AI commented Feb 15, 2026

Summary

Briefly explain the problem and what this PR changes.

  • Problem: Android release bundles (:composeApp:bundleRelease) were using CONFIGCAT_KEY_TEST instead of CONFIGCAT_KEY_PROD because BuildKonfig's flavor-based configuration wasn't being activated.
  • Solution: Clarified BuildKonfig configuration requires -Pbuildkonfig.flavor=release flag; added comprehensive testing and IDE configuration documentation.
  • Type: [ ] Feature [x] Bugfix [ ] Refactor [ ] Chore [ ] Docs

Context / Links

Implementation details

BuildKonfig doesn't auto-detect Android build types (debug/release). The defaultConfigs("release") block defines a flavor, not a build variant. Without the flavor flag, all builds use the default config.

Updated configuration comments:

// A. DEFAULT CONFIG (Used for debug/development builds)
defaultConfigs {
    buildConfigField(STRING, "CONFIGCAT_SDK_KEY", getSecret("CONFIGCAT_KEY_TEST"))
}

// B. RELEASE FLAVOR (Triggered by -Pbuildkonfig.flavor=release)
defaultConfigs("release") {
    buildConfigField(STRING, "CONFIGCAT_SDK_KEY", getSecret("CONFIGCAT_KEY_PROD", getSecret("CONFIGCAT_KEY_TEST")))
}

Correct release build command:

./gradlew :composeApp:bundleRelease -Pbuildkonfig.flavor=release

Android Studio IDE Configuration:

Added 5 options for configuring Android Studio's "Generate Signed Bundle / APK" menu:

  1. Global gradle.properties - Add buildkonfig.flavor=release to ~/.gradle/gradle.properties
  2. Project gradle.properties - Add to project file (not recommended, don't commit)
  3. Build Variants - Use Android Studio's Build Variants panel (limited support)
  4. Custom Run Configuration - Create reusable Gradle configuration with -Pbuildkonfig.flavor=release argument
  5. Terminal - Use built-in terminal to run Gradle command directly

Recommended approach: Use custom run configuration or terminal for explicit control.

Screenshots / API changes (if applicable)

N/A - Build configuration change only

Testing

Describe how this was tested and what scenarios were covered.

  • Unit tests
  • Integration / e2e tests
  • Manual tests

Steps / commands:

Created docs/BUILDKONFIG_SETUP.md with comprehensive documentation including:

4 verification methods:

  1. Generated file inspection: ./gradlew :composeApp:generateBuildKonfig -Pbuildkonfig.flavor=release → verify BuildKonfig.kt contains prod key
  2. Runtime logging: Add println(BuildKonfig.CONFIGCAT_SDK_KEY) to DI setup → confirm key in logcat
  3. APK decompilation: Extract and decompile release AAB → inspect BuildKonfig.class constant
  4. ConfigCat dashboard: Monitor which environment receives requests from installed release app

Platform coverage:

  • Android (with -Pbuildkonfig.flavor=release)
  • iOS (with -Pmode=release)
  • Desktop (with -Pmode=release)
  • CI/CD configuration examples

IDE integration:

  • 5 different Android Studio configuration options with pros/cons
  • Recommended workflows for development and release builds
  • Step-by-step instructions for each approach

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ase builds

Co-authored-by: ricky9667 <55730003+ricky9667@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 15, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -Xmx4G -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Upgrade version to 1.2.0 Fix Android release builds using Test ConfigCat SDK key instead of Production Feb 15, 2026
Copilot AI requested a review from ricky9667 February 15, 2026 05:12
@ricky9667
Copy link
Owner

@copilot What if i use "Generate Signed App Bundle or APK" menu option from Android Studio menu bar? How can i configure this option in my IDE?

Co-authored-by: ricky9667 <55730003+ricky9667@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 15, 2026

@copilot What if i use "Generate Signed App Bundle or APK" menu option from Android Studio menu bar? How can i configure this option in my IDE?

I've added comprehensive Android Studio IDE configuration instructions to the documentation (commit e4245fe).

5 options to configure Android Studio:

Option 1 (Recommended): Add buildkonfig.flavor=release to your global ~/.gradle/gradle.properties file. This makes all builds use the production key. Comment it out when doing debug builds.

Option 2: Add to project's gradle.properties (don't commit this change to Git).

Option 3: Build Variants panel - Note: Android Studio's "Generate Signed Bundle" dialog doesn't support passing Gradle properties directly.

Option 4 (Best for recurring use): Create a custom Gradle run configuration:

  • Run > Edit Configurations > + > Gradle
  • Tasks: bundleRelease
  • Arguments: -Pbuildkonfig.flavor=release

Option 5 (Most reliable): Use the built-in Terminal in Android Studio and run:

./gradlew :composeApp:bundleRelease -Pbuildkonfig.flavor=release

My recommendation: Use Option 4 (custom run configuration) or Option 5 (terminal) for the most explicit control. Options 1-2 modify gradle.properties which affects all builds globally.

See the complete guide in docs/BUILDKONFIG_SETUP.md.

@ricky9667
Copy link
Owner

Fixed directly in the #102 branch.

@ricky9667 ricky9667 closed this Feb 15, 2026
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.

2 participants