Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Documentation/ConfigurationManagement.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ android:
- feature_flags.yaml
```

## App Version

Set these top-level keys in the selected environment's `config.yaml` (including your custom config directory, if used):

```yaml
VERSION_CODE: 2
VERSION_NAME: '1.0.1'
```

- `VERSION_CODE` sets Android's `versionCode`. It must be an integer from `1` to `2100000000`; invalid values fail during Gradle configuration. Integer values and quoted integer strings are supported.
- `VERSION_NAME` sets the user-visible Android `versionName`; use a quoted string.
- If omitted, the values default to `1` and `'1.0.0'`, respectively.

Increment `VERSION_CODE` for each Google Play upload, using a value higher than any previously uploaded version for the same application ID. Changing `VERSION_NAME` alone does not satisfy this requirement.

## Available Third-Party Services
- **Firebase:** Analytics, Crashlytics, Cloud Messaging
- **Google:** Sign in and Sign up via Google
Expand Down
12 changes: 10 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
def config = configHelper.fetchConfig()
def appId = config.getOrDefault("APPLICATION_ID", "org.openedx.app")
def appVersionCode = config.getOrDefault("VERSION_CODE", 1)?.toString()
def appVersionName = config.getOrDefault("VERSION_NAME", "1.0.0")

if (!(appVersionCode ==~ /[0-9]+/) || !appVersionCode.isInteger() ||
appVersionCode.toInteger() < 1 || appVersionCode.toInteger() > 2100000000) {
throw new GradleException("VERSION_CODE must be an integer between 1 and 2100000000 in the YAML config.")
}
Comment on lines +3 to +9

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farhaanbukhsh I am very confused here. Why are we converting VERSION_CODE to string, compare against a regex, check !isInt, to cast toInt and then validate the range?

Why can't we simply do?

def appVersionCode = config.getOrDefault("VERSION_CODE", 1)
if (!appVersionCode.isInteger() || appVersion < 1 || appVersion > 2100000000) {
    throw...
}

Is it something with the way Gradle parses the YAML? Does it not preserve integers?


def themeDirectory = config.getOrDefault("THEME_DIRECTORY", "openedx")
def firebaseConfig = config.get('FIREBASE')
def firebaseEnabled = firebaseConfig?.getOrDefault('ENABLED', false)
Expand Down Expand Up @@ -35,8 +43,8 @@ android {
applicationId appId
minSdk min_sdk_version
targetSdk target_sdk_version
versionCode 1
versionName "1.0.0"
versionCode appVersionCode.toInteger()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to above comment, why do we need to keep it as a string and cast to int every time we need this value?

versionName appVersionName

resourceConfigurations += ["en", "uk"]

Expand Down
2 changes: 2 additions & 0 deletions default_config/dev/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
API_HOST_URL: 'http://localhost:8000'
APPLICATION_ID: 'org.openedx.app'
VERSION_CODE: 1
VERSION_NAME: '1.0.0'
ENVIRONMENT_DISPLAY_NAME: 'Localhost'
URI_SCHEME: ''
FEEDBACK_EMAIL_ADDRESS: 'support@example.com'
Expand Down
2 changes: 2 additions & 0 deletions default_config/prod/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
API_HOST_URL: 'http://localhost:8000'
APPLICATION_ID: 'org.openedx.app'
VERSION_CODE: 1
VERSION_NAME: '1.0.0'
ENVIRONMENT_DISPLAY_NAME: 'Localhost'
URI_SCHEME: ''
FEEDBACK_EMAIL_ADDRESS: 'support@example.com'
Expand Down
2 changes: 2 additions & 0 deletions default_config/stage/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
API_HOST_URL: 'http://localhost:8000'
APPLICATION_ID: 'org.openedx.app'
VERSION_CODE: 1
VERSION_NAME: '1.0.0'
ENVIRONMENT_DISPLAY_NAME: 'Localhost'
URI_SCHEME: ''
FEEDBACK_EMAIL_ADDRESS: 'support@example.com'
Expand Down
Loading