android-samples/README.md
Dale Hawkins ad237b2607
feat: Introduce FireMarkers Sample (#2325)
* feat: Adds a new sample demonstrating how to use Google Maps with Firebase Realtime Database on Android.

* feat(viewmodel): Add tests and error handling for controller logic

This commit introduces unit tests for the `MarkersViewModel` and enhances the app's robustness by adding error handling and improving documentation.

- **ViewModel Unit Tests:** Adds unit tests for `MarkersViewModel` using Mockito, Turbine, and Robolectric. The tests verify the controller/agent logic, ensuring that state is correctly managed based on the `controllerId` from Firebase. It also tests the new error reporting mechanism.
- **Error Handling:** Implements a `SharedFlow` in the `MarkersViewModel` to propagate database errors to the UI. The `MainActivity` now observes this flow and displays errors to the user in a `Snackbar`.
- **Architecture Documentation:** Replaces the static SVG architecture diagram with a more detailed Mermaid diagram in `ARCHITECTURE.md`. The new documentation explains the controller/agent synchronization pattern used for animations.
- **Dependency Updates:** Upgrades Gradle to version 9.1.0 and adds `mockito-kotlin` and `turbine` as test dependencies. The `libs.versions.toml` file is reorganized for better clarity.

* chore: Configure Gradle JVM args and expose ViewModel property

This commit includes two maintenance changes: enabling custom JVM arguments for the Gradle daemon and updating the visibility of a property in the `MarkersViewModel`.

* chore: Annotate the version catalog and build.gradle.kts file

- **Gradle Build Documentation:** Introduces extensive documentation and organization to the `libs.versions.toml` and `app/build.gradle.kts` files. Dependencies, plugins, and versions are now grouped logically with comments explaining their purpose, improving maintainability and clarity.
- **README Update:** The main `README.md` is updated to include a description of the new `FireMarkers` sample.
- **Manifest Cleanup:** Removes the redundant `android:label` from the `MainActivity` in the manifest.

* chore: adds copyright to the new source files

* chore: headers

---------

Co-authored-by: Enrique López Mañas <eenriquelopez@gmail.com>
2025-10-31 10:23:30 +03:00

5.3 KiB

Build

Contributors License StackOverflow Discord

Google Maps SDK for Android Samples

Description

Samples demonstrating how to use Maps SDK for Android.

Samples in this repo (if more than one)

This repo contains the following samples:

  1. ApiDemos: A collection of small demos showing most features of the Maps SDK for Android.
  2. FireMarkers: Demonstrates how to use Firebase Realtime Database to drive synchronized, live animations on a Google Map across multiple devices using a controller/agent architecture.
  3. WearOS: Displays a map on a Wear OS device. This sample demonstrates the basic setup required for a gradle-based Android Studio project.
  4. Tutorials: Samples associated with tutorials in the developer's guide. See each sample for a link to the associated guide.
  5. Snippets: Snippets for code found in https://developers.google.com/maps/documentation/android-sdk

Requirements

To run the samples, you will need:

  • To sign up with Google Maps Platform
  • A Google Maps Platform project with the Maps SDK for Android enabled
  • An API key associated with the project above ... follow the API key instructions if you're new to the process
  • See each sample for pre-requisites.
  • All require up-to-date versions of the Android build tools and the Android support repository.

Running the sample(s)

  1. Download the samples by cloning this repository
  2. In the welcome screen of Android Studio, select "Open an Existing project"
  3. Select one of the sample directories from this repository

Alternatively, use the gradlew build command to build the project directly or download an APK under releases.

Contributing

Contributions are welcome and encouraged! If you'd like to contribute, send us a pull request and refer to our code of conduct and contributing guide.

Terms of Service

This sample uses Google Maps Platform services. Use of Google Maps Platform services through this sample is subject to the Google Maps Platform Terms of Service.

If your billing address is in the European Economic Area, effective on 8 July 2025, the Google Maps Platform EEA Terms of Service will apply to your use of the Services. Functionality varies by region. Learn more.

This sample is not a Google Maps Platform Core Service. Therefore, the Google Maps Platform Terms of Service (e.g. Technical Support Services, Service Level Agreements, and Deprecation Policy) do not apply to the code in this sample.

Support

This sample is offered via an open source license. It is not governed by the Google Maps Platform Support Technical Support Services Guidelines, the SLA, or the Deprecation Policy. However, any Google Maps Platform services used by the sample remain subject to the Google Maps Platform Terms of Service.

If you find a bug, or have a feature request, please file an issue on GitHub. If you would like to get answers to technical questions from other Google Maps Platform developers, ask through one of our developer community channels. If you'd like to contribute, please check the contributing guide.

You can also discuss this sample on our Discord server.