Fix: assembleDebug fails on a fresh clone without keystore.properties#6
Open
7MS8 wants to merge 1 commit into
Open
Fix: assembleDebug fails on a fresh clone without keystore.properties#67MS8 wants to merge 1 commit into
7MS8 wants to merge 1 commit into
Conversation
assembleDebug currently fails on a fresh clone with "Cannot convert ''
to File" because the release signingConfig block unconditionally calls
file(keystoreProperties.getProperty("storeFile", "")) — Gradle
evaluates the whole android{} DSL at configuration time regardless of
which build type is requested, so this breaks debug builds too when no
keystore.properties is present (it's gitignored, so every fresh clone
hits this).
Wrapping both the signingConfigs.create("release") block and the
signingConfig assignment in release{} behind
keystorePropertiesFile.exists() lets assembleDebug (and assembleRelease
without a keystore) build cleanly, while release builds still pick up
signing once keystore.properties exists.
Verified: ./gradlew clean assembleDebug succeeds with no
keystore.properties in the tree at all.
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.
What's broken
./gradlew assembleDebugfails immediately on a fresh clone (nokeystore.properties, which is gitignored — as documented in the README/CLAUDE.md):Cause:
signingConfigs { create("release") { storeFile = file(keystoreProperties.getProperty("storeFile", "")) ... } }runs unconditionally. Gradle evaluates the wholeandroid {}DSL at configuration time regardless of which task is requested, so evenassembleDebughitsfile("")and crashes.Fix
Guard both the
signingConfigs.create("release")block and thesigningConfig = ...assignment inrelease {}behindkeystorePropertiesFile.exists(). Release builds still pick up signing exactly as before oncekeystore.propertiesexists; debug builds (andassembleReleasewithout a keystore, which just produces an unsigned APK) no longer crash.Verified
Ran into this while evaluating the project as a translation backend for another app — happy to adjust the approach if you'd prefer a different guard style (e.g. failing loudly with a clearer message instead of silently skipping signing).