After you have completed the common prerequisites you will need the following:
- Android Studio Ladybug or newer
Assuming you have Android Studio and other prerequisites installed, you can build and run the app by following these steps:
- Create an application at https://portal.ditto.live/. Make note of the database ID (used to be called app ID) and online playground token.
- Copy the
.env.samplefile at the top level of thequickstartrepo to.envand add your Database ID (used to be called AppId), Online Playground Token, and Auth URL. - Launch Android Studio and open the
quickstart/android-javadirectory. - In Android Studio, select a connected Android device, or create and launch an Android emulator and select it as the destination, then choose the Run > Run 'app' menu item.
The app will build and run on the selected device or emulator. You can add, edit, and delete tasks in the app.
If you run the app on additional devices or emulators, the data will be synced between them.
Compatible with Android Automotive OS (AAOS)
The Android app is a simple to-do list app that demonstrates how to use the Ditto Android SDK to sync data with other devices. It is implemented using Java and Android Views using an Activity and a programmatically implemented RecyclerView.
The Ditto v5 SDK ships as a Kotlin module (com.ditto:ditto-kotlin-android) and exposes some APIs as suspend functions. To keep the application code idiomatic Java, this project uses a small Kotlin bridge file, DittoHelper.kt, that wraps the suspending APIs with runBlocking and exposes @JvmStatic entry points. All application logic — MainActivity, Task, and TaskAdapter — remains in Java.
It is assumed that the reader is familiar with Android development and with Java/Activity/RecyclerView, but needs some guidance on how to use Ditto. The following is a summary of the key parts of integration with Ditto.
In app/build.gradle.kts, you will see this line that causes Android Studio
to download the Ditto SDK from Maven Central and add it to the project:
implementation(libs.ditto)This line in gradle/libs.versions.toml specifies which version of the Ditto
SDK to use:
ditto = "5.0.0"To use a newer version of the SDK, change the version number on this line.