Skip to content

Draft: Update Quickstart for Android Java to v5 - DO NOT MERGE#268

Draft
Aaron LaBeau (biozal) wants to merge 1 commit intomainfrom
da-138-update-v5-android-java
Draft

Draft: Update Quickstart for Android Java to v5 - DO NOT MERGE#268
Aaron LaBeau (biozal) wants to merge 1 commit intomainfrom
da-138-update-v5-android-java

Conversation

@biozal
Copy link
Copy Markdown
Contributor

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-rc.3).

Key changes

  • SDK artifact: Changed from live.ditto:ditto:4.13.1 to com.ditto:ditto-kotlin-android:5.0.0-rc.3 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-rc.3, 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

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.

1 participant