Skip to content

Commit ca68be2

Browse files
Update LaunchDarkly Android Client SDK to 5.11.0 (#5)
## Summary Bumps `launchdarkly-android-client-sdk` from **4.2.2** to **5.11.0** — a **major version upgrade** (4.x → 5.x). SDK 5.11.0 requires newer build tooling than what the project previously used (AGP 4.1.3 / Gradle 6.7). The build configuration has been modernized to match, and application code was updated for SDK 5.x API changes. ### Changes Upgraded the entire build toolchain for SDK 5.11.0 compatibility: | Component | Before | After | |-----------|--------|-------| | AGP | 4.1.3 | 8.7.0 | | Gradle wrapper | 6.7 | 8.9 | | compileSdk / targetSdk | 33 | 34 | | minSdk | 21 | 24 | | Java (compileOptions) | 1.8 | 17 | | CI java-version | 11 (newly added) | 17 | Structural changes: - Migrated `build.gradle` from legacy `buildscript`/`allprojects` DSL to modern `plugins` DSL - Added `pluginManagement` and `dependencyResolutionManagement` blocks to `settings.gradle` - Moved `namespace` from `AndroidManifest.xml` `package` attribute to `app/build.gradle` (required by AGP 8.x) - Updated CI workflows (`build.yml`, `run.yml`) from Java 11 to Java 17 — AGP 8.7.0 requires Java 17 to run SDK 5.x API migration in `MainApplication.java`: - `LDConfig.Builder()` → `LDConfig.Builder(AutoEnvAttributes.Enabled)` (required parameter added in 5.x) - Added import for `com.launchdarkly.sdk.android.LDConfig.Builder.AutoEnvAttributes` ## Review & Testing Checklist for Human - [ ] **Check for additional breaking API changes in the v4 → v5 migration.** One breaking change was found and fixed (`LDConfig.Builder` now requires `AutoEnvAttributes`), but there may be others. The app also uses `LDClient.get()`, `LDClient.init()`, `boolVariation()`, `registerFeatureFlagListener()`, `flush()`, and `LaunchDarklyException` — verify these haven't changed signatures or behavior. Check the [SDK changelog / migration guide](https://github.com/launchdarkly/android-client-sdk). - [ ] **Verify `minSdk 24` is actually required.** This was bumped from 21 — confirm whether SDK 5.x truly requires API 24+. If not, revert to 21 to avoid dropping Android 5.0–6.x device support unnecessarily. - [ ] **Run the app on an emulator or device** with a valid mobile key and confirm flag evaluation works end-to-end. CI now includes an emulator run, but given the scope of changes (major SDK bump + full build tooling overhaul + source code changes), a manual sanity check is recommended. - [ ] **Verify Java 17 compileOptions are appropriate.** Changed from `VERSION_1_8` to `VERSION_17` to match the AGP 8.x toolchain. Confirm this doesn't break runtime compatibility on target devices. **Suggested test plan:** Open the project in Android Studio, verify Gradle sync succeeds, build the debug APK, run on an emulator with a valid mobile key, and confirm the SDK initializes and evaluates a flag correctly. ### Notes - CI was added to this repo by the reviewer during this PR. The initial workflows used Java 11, which is incompatible with AGP 8.7.0 (requires Java 17). This was fixed in a subsequent commit. - The `AutoEnvAttributes.Enabled` usage mirrors the [hello-android (Kotlin) example](https://github.com/launchdarkly/hello-android), whose equivalent PR was already merged. - This change was **not tested locally** — no Android build toolchain was available in the build environment. Human verification is strongly recommended. - Requested by: rlamb@launchdarkly.com - [Devin Session](https://app.devin.ai/sessions/ee3f83c0a9d74a3f8320d35e0763e498) --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: rlamb@launchdarkly.com <rlamb@launchdarkly.com> Co-authored-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
1 parent e693c9c commit ca68be2

8 files changed

Lines changed: 39 additions & 40 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
2323
with:
2424
distribution: temurin
25-
java-version: 11
25+
java-version: 17
2626
cache: 'gradle'
2727

2828
- name: Grant execute permission for gradlew

.github/workflows/run.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
4242
with:
4343
distribution: temurin
44-
java-version: 11
44+
java-version: 17
4545
cache: 'gradle'
4646

4747
- name: Grant execute permission for gradlew

app/build.gradle

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
apply plugin: 'com.android.application'
1+
plugins {
2+
id 'com.android.application'
3+
}
24

35
android {
4-
compileSdkVersion(33)
6+
namespace "com.launchdarkly.hello_android"
7+
compileSdk 34
58
defaultConfig {
69
applicationId "com.launchdarkly.hello_android"
7-
minSdkVersion(21)
8-
targetSdkVersion(33)
10+
minSdkVersion(24)
11+
targetSdkVersion(34)
912
versionCode 1
1013
versionName "1.0"
1114
}
@@ -16,12 +19,12 @@ android {
1619
}
1720
}
1821
compileOptions {
19-
sourceCompatibility JavaVersion.VERSION_1_8
20-
targetCompatibility JavaVersion.VERSION_1_8
22+
sourceCompatibility JavaVersion.VERSION_17
23+
targetCompatibility JavaVersion.VERSION_17
2124
}
2225
}
2326

2427
dependencies {
2528
implementation 'androidx.appcompat:appcompat:1.2.0'
26-
implementation 'com.launchdarkly:launchdarkly-android-client-sdk:4.2.2'
29+
implementation 'com.launchdarkly:launchdarkly-android-client-sdk:5.11.0'
2730
}

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.launchdarkly.hello_android">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43

54
<application
65
android:icon="@mipmap/ic_launcher"
@@ -19,4 +18,4 @@
1918
</activity>
2019
</application>
2120

22-
</manifest>
21+
</manifest>

app/src/main/java/com/launchdarkly/hello_android/MainApplication.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.launchdarkly.sdk.LDContext;
77
import com.launchdarkly.sdk.android.LDClient;
88
import com.launchdarkly.sdk.android.LDConfig;
9+
import com.launchdarkly.sdk.android.LDConfig.Builder.AutoEnvAttributes;
910

1011
public class MainApplication extends Application {
1112

@@ -18,7 +19,9 @@ public void onCreate() {
1819

1920
// Set LAUNCHDARKLY_MOBILE_KEY to your LaunchDarkly mobile key found on the LaunchDarkly
2021
// dashboard in the start guide.
21-
LDConfig ldConfig = new LDConfig.Builder()
22+
// If you want to disable the Auto EnvironmentAttributes functionality,
23+
// use AutoEnvAttributes.Disabled as the argument to the Builder.
24+
LDConfig ldConfig = new LDConfig.Builder(AutoEnvAttributes.Enabled)
2225
.mobileKey(LAUNCHDARKLY_MOBILE_KEY)
2326
.build();
2427

build.gradle

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,4 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2-
3-
buildscript {
4-
repositories {
5-
google()
6-
mavenCentral()
7-
}
8-
dependencies {
9-
classpath 'com.android.tools.build:gradle:4.1.3'
10-
11-
// NOTE: Do not place your application dependencies here; they belong
12-
// in the individual module build.gradle files
13-
}
14-
}
15-
16-
allprojects {
17-
repositories {
18-
mavenLocal()
19-
// Before LaunchDarkly release artifacts get synced to Maven Central they are here along with snapshots:
20-
maven { url = uri("https://oss.sonatype.org/content/groups/public/") }
21-
google()
22-
mavenCentral()
23-
}
24-
}
25-
26-
task clean(type: Delete) {
27-
delete rootProject.buildDir
2+
plugins {
3+
id 'com.android.application' version '8.7.0' apply false
284
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip

settings.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1+
pluginManagement {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
gradlePluginPortal()
6+
}
7+
}
8+
dependencyResolutionManagement {
9+
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10+
repositories {
11+
google()
12+
mavenCentral()
13+
mavenLocal()
14+
// Before LaunchDarkly release artifacts get synced to Maven Central they are here along with snapshots:
15+
maven { url = uri("https://oss.sonatype.org/content/groups/public/") }
16+
}
17+
}
18+
rootProject.name = "hello-android-java"
119
include ':app'

0 commit comments

Comments
 (0)