Skip to content

Update Quickstart for Android Java to v5#268

Merged
Aaron LaBeau (biozal) merged 4 commits intomainfrom
da-138-update-v5-android-java
May 5, 2026
Merged

Update Quickstart for Android Java to v5#268
Aaron LaBeau (biozal) merged 4 commits intomainfrom
da-138-update-v5-android-java

Conversation

@biozal
Copy link
Copy Markdown
Contributor

@biozal Aaron LaBeau (biozal) commented Apr 21, 2026

Summary

Migrates the Android Java quickstart app from Ditto SDK v4 (live.ditto:ditto:4.13.1) to v5 (com.ditto:ditto-kotlin-android:5.0.0).

Key changes

  • SDK artifact: Changed from live.ditto:ditto:4.13.1 to com.ditto:ditto-kotlin-android:5.0.0 in gradle/libs.versions.toml
  • Package rename: All imports updated from live.ditto.* to com.ditto.kotlin.*
  • New Kotlin bridge (DittoHelper.kt): The v5 Kotlin SDK uses suspend functions (e.g. store.execute()), which aren't directly callable from Java. DittoHelper wraps these with runBlocking to provide synchronous Java-friendly static methods for initialization, auth, CRUD operations, subscriptions, observers, and sync control.
  • Initialization rewrite: Replaced DittoIdentity.OnlinePlayground + DefaultAndroidDittoDependencies with DittoConfig + DittoFactory.create(). Removed updateTransportConfig() (websocket URL now handled by server config), disableSyncWithV3(), and ALTER SYSTEM SET DQL_STRICT_MODE = false (no longer needed in v5).
  • Authentication: Replaced inline playground token passing with auth.expirationHandler + auth.login() pattern using DittoAuthenticationProvider.development().
  • Query result parsing: DittoQueryResultItem.getValue() (Map) replaced with DittoQueryResultItem.jsonString() + JSONObject parsing in Task.fromQueryItem().
  • Permissions: Replaced DittoSyncPermissions (removed in v5) with manual Android permission checks for Bluetooth, location, and nearby Wi-Fi.
  • Exception handling: Changed catch (DittoError e) to catch (Exception e) since DittoException extends RuntimeException (unchecked) in v5.
  • BuildConfig fix: Added envValue() helper to strip shell-style quotes from .env values, preventing double-quoted BuildConfig strings.
  • Removed Jetpack Compose: Removed kotlin-compose plugin, compose = true build feature, and all Compose dependencies. This app uses XML layouts, and the Compose dependencies were injecting ComponentActivity and PreviewActivity into the merged manifest with exported="true" but no intent filters, which prevented Android Studio from running/debugging the app.

Files changed

File Change
gradle/libs.versions.toml SDK version 4.13.1 → 5.0.0, artifact live.ditto:dittocom.ditto:ditto-kotlin-android
app/build.gradle.kts Removed Compose plugin/deps/feature, added envValue() for BuildConfig quote stripping
app/src/main/java/.../DittoHelper.kt New — Kotlin bridge wrapping v5 suspend functions for Java callers
app/src/main/java/.../MainActivity.java Rewrote init, auth, CRUD, permissions, sync for v5 APIs via DittoHelper
app/src/main/java/.../Task.java Updated imports, switched to JSON-based query result parsing

Test plan

  • Build succeeds: ./gradlew assembleDebug
  • App launches and displays task list on emulator or device
  • Create, toggle, edit, and delete tasks
  • Sync toggle works (start/stop)
  • Tasks sync between two devices via Ditto cloud
  • Android Studio can run and debug the app without manifest errors

🤖 Generated with Claude Code

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the Android Java quickstart from Ditto SDK v4 to Ditto SDK v5 by switching the dependency coordinates/version and updating the app’s initialization, auth, DQL execution, and query-result parsing to the new com.ditto.kotlin.* APIs (with a Kotlin bridge for Java callers).

Changes:

  • Update Ditto dependency to com.ditto:ditto-kotlin-android:5.0.0-rc.3 and adjust imports accordingly.
  • Introduce DittoHelper.kt to bridge v5 Kotlin suspend APIs for Java usage and refactor MainActivity to use it.
  • Remove Jetpack Compose plugin/dependencies and add .env value unquoting for BuildConfig generation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
android-java/gradle/libs.versions.toml Updates Ditto SDK version and artifact coordinates for v5.
android-java/app/build.gradle.kts Removes Compose setup and tweaks BuildConfig env parsing/fields.
android-java/app/src/main/java/com/example/dittotasks/DittoHelper.kt Adds a Kotlin-to-Java bridge for Ditto v5 suspend-based APIs.
android-java/app/src/main/java/com/example/dittotasks/MainActivity.java Refactors initialization/auth/sync and CRUD to call Ditto v5 through DittoHelper.
android-java/app/src/main/java/com/example/dittotasks/Task.java Switches query item parsing to JSON string parsing for v5 results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread android-java/gradle/libs.versions.toml
Comment thread android-java/app/src/main/java/com/example/dittotasks/Task.java
Comment thread android-java/app/src/main/java/com/example/dittotasks/MainActivity.java Outdated
Comment thread android-java/app/build.gradle.kts Outdated
@biozal Aaron LaBeau (biozal) changed the title Draft: Update Quickstart for Android Java to v5 - DO NOT MERGE Update Quickstart for Android Java to v5 - DO NOT MERGE May 5, 2026
@biozal Aaron LaBeau (biozal) changed the title Update Quickstart for Android Java to v5 - DO NOT MERGE Update Quickstart for Android Java to v5 May 5, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread android-java/app/build.gradle.kts Outdated
Comment thread android-java/gradle/libs.versions.toml
Comment thread android-java/README.md
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:shipit:

@biozal Aaron LaBeau (biozal) merged commit 3876af2 into main May 5, 2026
1 check passed
@biozal Aaron LaBeau (biozal) deleted the da-138-update-v5-android-java branch May 5, 2026 21:32
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.

3 participants