Skip to content

Commit 7e0db8c

Browse files
authored
feat!: update to Maps SDK 2.0.0 (#2346)
* fix!: upgrade to Maps SDK v20 and resolve build issues - Upgrade Google Maps SDK to v20.0.0 (BREAKING CHANGE: requires new renderer). - Fix WearOS build by replacing deprecated kotlinOptions with jvmToolchain. - Resolve WearOS dependency conflicts by using Kotlin BOM. - Migrate WearOS dependencies and SDK versions to Version Catalog. - Refactor Version Catalog: extract versions and organize groups. - Fix FireMarkers sample: correct Google Services plugin application logic. - FireMarkers: Add explicit error handling for 'Permission Denied'. BREAKING CHANGE: This release upgrades the Maps SDK to v20.0.0, which may require code changes for the new renderer and other API adjustments. * chore: verify build health and remove rx samples - Create scripts/verify_all.sh for local verification - Update CI to run tests and lint - Remove deprecated snippets/app-rx module - Fix FireMarkers unit tests - Update README with verification instructions * fix: add missing license header to verify_all.sh * fix: remove app-rx from lint workflow * fix(ci): remove foojay-resolver and rely on CI JDK 21 * fix: address review comments (README typo, settings repo mode) * feat: add script to sync documentation versions with version catalog * chore: finalize build settings and documentation versions - CI: Upgrade to Java 21 and add python docs check - Settings: Allow local repository overrides - Docs: Annotate WearOS dependencies with hardcoded versions * chore: expose version catalog instructions in docs and update sync script * chore: restore snippets/app-rx to preserve documentation region tags
1 parent f128137 commit 7e0db8c

File tree

21 files changed

+423
-124
lines changed

21 files changed

+423
-124
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ jobs:
111111
./gradlew :snippets:app-utils-ktx:assembleDebug
112112
./gradlew :snippets:app-compose:assembleDebug
113113
./gradlew :snippets:app-places-ktx:assembleDebug
114-
./gradlew :snippets:app-rx:assembleDebug
115114
./gradlew :snippets:app-utils:assembleDebug
116115
117116
build-tutorials:
@@ -134,13 +133,25 @@ jobs:
134133
run: |
135134
./gradlew :tutorials:kotlin:Polygons:assembleDebug
136135
137-
test: # used as required status check
136+
test:
138137
runs-on: ubuntu-latest
138+
timeout-minutes: 60
139139
needs:
140140
- build-ApiDemos
141141
- build-WearOS
142+
- build-FireMarkers
142143
- build-Snippets
143144
- build-tutorials
144-
- build-FireMarkers
145145
steps:
146-
- run: echo "Fail if all other steps are not successful"
146+
- uses: actions/checkout@v4
147+
- name: set up Java 21
148+
uses: actions/setup-java@v4
149+
with:
150+
distribution: 'adopt'
151+
java-version: '21'
152+
153+
- name: Run Unit Tests
154+
run: ./gradlew testDebugUnitTest
155+
156+
- name: Run Lint
157+
run: ./gradlew lintDebug

.github/workflows/lint.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ jobs:
3131
uses: actions/setup-java@v4
3232
with:
3333
distribution: 'adopt'
34-
java-version: '17'
34+
java-version: '21'
35+
36+
- name: Set up Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: '3.x'
40+
41+
- name: Check documentation versions
42+
run: python3 scripts/update_docs_versions.py --check
3543

3644
- name: Setup Gradle
3745
uses: gradle/actions/setup-gradle@v5
@@ -44,7 +52,6 @@ jobs:
4452
./gradlew :snippets:app:lintGmsDebug
4553
./gradlew :snippets:app-utils:lintDebug
4654
./gradlew :snippets:app-utils-ktx:lintDebug
47-
./gradlew :snippets:app-rx:lintDebug
4855
./gradlew :snippets:app-places-ktx:lintDebug
4956
./gradlew :snippets:app-ktx:lintDebug
5057
./gradlew :snippets:app-compose:lintDebug
@@ -87,12 +94,6 @@ jobs:
8794
sarif_file: snippets/app-utils-ktx/build/reports/lint-results-debug.sarif
8895
category: snippets-app-utils-ktx
8996

90-
- name: Upload SARIF for snippets:app-rx
91-
uses: github/codeql-action/upload-sarif@v3
92-
with:
93-
sarif_file: snippets/app-rx/build/reports/lint-results-debug.sarif
94-
category: snippets-app-rx
95-
9697
- name: Upload SARIF for snippets:app-places-ktx
9798
uses: github/codeql-action/upload-sarif@v3
9899
with:

FireMarkers/app/build.gradle.kts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@ plugins {
4545
alias(libs.plugins.kotlin.serialization) // Provides Kotlin serialization capabilities.
4646
}
4747

48-
gradle.projectsEvaluated {
49-
if (rootProject.file("app/google-services.json").exists()) {
50-
project(":app").pluginManager.apply("com.google.gms.google-services")
51-
println("Applied Google Services plugin.")
52-
} else {
53-
println("google-services.json not found — skipping plugin application")
54-
}
48+
if (file("google-services.json").exists()) {
49+
apply(plugin = "com.google.gms.google-services")
50+
println("Applied Google Services plugin.")
51+
} else {
52+
println("google-services.json not found — skipping Google Services plugin")
5553
}
5654

5755
android {

FireMarkers/app/src/main/java/com/example/firemarkers/FireMarkersApplication.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class FireMarkersApplication : Application() {
5959
val mapsApiKey =
6060
bundle.getString("com.google.android.geo.API_KEY") // Key name is important!
6161

62-
if (mapsApiKey == null || mapsApiKey.isBlank() || mapsApiKey == "DEFAULT_API_KEY") {
62+
if (mapsApiKey.isNullOrBlank() || mapsApiKey == "DEFAULT_API_KEY") {
6363
Toast.makeText(
6464
this,
6565
"Maps API Key was not set in secrets.properties",

FireMarkers/app/src/main/java/com/example/firemarkers/viewmodel/MarkersViewModel.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@ class MarkersViewModel @Inject constructor(
154154
}
155155

156156
override fun onCancelled(error: DatabaseError) {
157-
Log.e(TAG, "[$viewModelId] Database error on markers: ${error.message}")
158-
viewModelScope.launch {
159-
_errorEvents.emit("Database error on markers: ${error.message}")
160-
}
157+
handleDatabaseError(error, "markers")
161158
}
162159
})
163160
}
@@ -187,14 +184,23 @@ class MarkersViewModel @Inject constructor(
187184
}
188185

189186
override fun onCancelled(error: DatabaseError) {
190-
Log.e(TAG, "[$viewModelId] DB error on animation: ${error.message}")
191-
viewModelScope.launch {
192-
_errorEvents.emit("DB error on animation: ${error.message}")
193-
}
187+
handleDatabaseError(error, "animation")
194188
}
195189
})
196190
}
197191

192+
private fun handleDatabaseError(error: DatabaseError, context: String) {
193+
val msg = if (error.code == DatabaseError.PERMISSION_DENIED) {
194+
"Permission Denied ($context): Check your Firebase Database Rules."
195+
} else {
196+
"Database error ($context): ${error.message}"
197+
}
198+
Log.e(TAG, "[$viewModelId] $msg")
199+
viewModelScope.launch {
200+
_errorEvents.emit(msg)
201+
}
202+
}
203+
198204
/**
199205
* Toggles the animation state (running/paused) in Firebase.
200206
*

FireMarkers/app/src/test/java/com/example/firemarkers/viewmodel/MarkersViewModelTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class MarkersViewModelTest {
156156
listenerCaptor.firstValue.onCancelled(error)
157157
testDispatcher.scheduler.advanceUntilIdle()
158158

159-
assertThat(errorMessage).isEqualTo("DB error on animation: Test Error")
159+
assertThat(errorMessage).isEqualTo("Database error (animation): Test Error")
160160
job.cancel()
161161
}
162162
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mock-maker-inline

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ To run the samples, you will need:
4343
1. In the welcome screen of Android Studio, select "Open an Existing project"
4444
1. Select one of the sample directories from this repository
4545

46+
## Verifying the build
47+
48+
To verify that all samples build and pass tests, run:
49+
50+
```bash
51+
./scripts/verify_all.sh
52+
```
53+
4654
Alternatively, use the `gradlew build` command to build the project directly or download an APK
4755
under [releases](https://github.com/googlemaps/android-samples/releases).
4856

WearOS/Wearable/build.gradle.kts

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Google LLC
2+
* Copyright 2026 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,20 +21,20 @@ plugins {
2121
}
2222

2323
android {
24-
compileSdk = 35
24+
compileSdk = libs.versions.compileSdk.get().toInt()
2525

2626
defaultConfig {
2727
applicationId = "com.example.wearos"
28-
minSdk = 23
29-
targetSdk = 31
28+
minSdk = libs.versions.minSdk.get().toInt()
29+
targetSdk = libs.versions.targetSdk.get().toInt()
3030
versionCode = 1
3131
versionName = libs.versions.versionName.get()
3232
}
3333

3434
buildTypes {
3535
getByName("release") {
3636
isMinifyEnabled = false
37-
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
37+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
3838
}
3939
}
4040

@@ -45,10 +45,6 @@ android {
4545
sarifOutput = layout.buildDirectory.file("reports/lint-results-debug.sarif").get().asFile
4646
}
4747

48-
kotlinOptions {
49-
jvmTarget = "21"
50-
}
51-
5248
kotlin {
5349
jvmToolchain(21)
5450
}
@@ -57,15 +53,37 @@ android {
5753
// [START maps_wear_os_dependencies]
5854
dependencies {
5955
// [START_EXCLUDE]
60-
implementation("androidx.core:core-ktx:1.15.0")
61-
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21")
56+
implementation(libs.core.ktx)
57+
implementation(platform(libs.kotlin.bom))
58+
implementation(libs.kotlin.stdlib)
6259
// [END_EXCLUDE]
63-
compileOnly("com.google.android.wearable:wearable:2.9.0")
64-
implementation("com.google.android.support:wearable:2.9.0")
65-
implementation("com.google.android.gms:play-services-maps:19.0.0")
60+
// Modern Android projects use version catalogs to manage dependencies. To include the necessary dependencies,
61+
// first add the following to your libs.versions.toml file:
62+
//
63+
// [versions]
64+
// playServicesMaps = "20.0.0"
65+
// wear = "1.3.0"
66+
// wearable = "2.9.0"
67+
//
68+
// [libraries]
69+
// play-services-maps = { group = "com.google.android.gms", name = "play-services-maps", version.ref = "playServicesMaps" }
70+
// wear = { group = "androidx.wear", name = "wear", version.ref = "wear" }
71+
// wearable-compile = { group = "com.google.android.wearable", name = "wearable", version.ref = "wearable" }
72+
// wearable-support = { group = "com.google.android.support", name = "wearable", version.ref = "wearable" }
73+
74+
compileOnly(libs.wearable.compile)
75+
implementation(libs.wearable.support)
76+
implementation(libs.play.services.maps)
6677

6778
// This dependency is necessary for ambient mode
68-
implementation("androidx.wear:wear:1.3.0")
79+
implementation(libs.wear)
80+
81+
// If your project does not use a version catalog, you can use the following dependencies instead:
82+
//
83+
// compileOnly("com.google.android.wearable:wearable:2.9.0")
84+
// implementation("com.google.android.support:wearable:2.9.0")
85+
// implementation("com.google.android.gms:play-services-maps:20.0.0")
86+
// implementation("androidx.wear:wear:1.3.0")
6987
}
7088
// [END maps_wear_os_dependencies]
7189

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#This file is generated by updateDaemonJvm
2+
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c5760d82d08e6c26884debb23736ea57/redirect
3+
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/879378f84c64b2c76003b97a32968399/redirect
4+
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c5760d82d08e6c26884debb23736ea57/redirect
5+
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/879378f84c64b2c76003b97a32968399/redirect
6+
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/021e528cbed860c875a9016f29ee13c1/redirect
7+
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/6141bf023dcc7a96c47cad75c59b054e/redirect
8+
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c5760d82d08e6c26884debb23736ea57/redirect
9+
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/879378f84c64b2c76003b97a32968399/redirect
10+
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/9b6bab41c3ef2acea6116b7821b8dc11/redirect
11+
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/a6eb06d81d82a782734ef3b616ba2684/redirect
12+
toolchainVendor=JETBRAINS
13+
toolchainVersion=21

0 commit comments

Comments
 (0)