Skip to content

Commit 1582916

Browse files
committed
feat!: update Maps SDK to v20.0.0 and add internal usage attribution
Updates the Maps SDK dependencies and implements internal usage attribution using androidx.startup. Changes: - Replaced manual initialization with AttributionIdInitializer using androidx.startup. - Removed GoogleMapsInitializer and MapsComposeApplication (Breaking Change). - Updated README.md with attribution opt-out instructions. - Added installAndLaunch Gradle task for easier demo app testing. - Fixed ScaleBarTests density calculation. - Updated minSdk overrides for test dependencies. Breaking Changes: - GoogleMapsInitializer and MapsComposeApplication have been removed. Initialization is now handled automatically by androidx.startup. - minSdk is now 23.
1 parent d213333 commit 1582916

15 files changed

Lines changed: 116 additions & 601 deletions

File tree

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,21 @@ The colors of the text, line, and shadow are also all configurable (e.g., based
497497

498498
## Internal usage attribution ID
499499

500-
This library calls the MapsApiSettings.addInternalUsageAttributionId method, which helps Google
501-
understand which libraries and samples are helpful to developers and is optional. Instructions for
502-
opting out of the identifier are provided in
503-
[reference documentation](maps-compose/src/main/java/com/google/maps/android/compose/internal/GoogleMapsInitializer.kt#L77-L82).
500+
This library calls the `addInternalUsageAttributionId` method, which helps Google understand which libraries and samples are helpful to developers and is optional. Instructions for opting out of the identifier are provided below.
501+
502+
If you wish to disable this, you can do so by removing the initializer in your `AndroidManifest.xml` using the `tools:node="remove"` attribute:
503+
504+
```xml
505+
<provider
506+
android:name="androidx.startup.InitializationProvider"
507+
android:authorities="${applicationId}.androidx-startup"
508+
android:exported="false"
509+
tools:node="merge">
510+
<meta-data
511+
android:name="com.google.maps.android.compose.utils.attribution.AttributionIdInitializer"
512+
tools:node="remove" />
513+
</provider>
514+
```
504515

505516
## Contributing
506517

build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,11 @@ allprojects {
3535
// {x-release-please-start-version}
3636
version = "7.0.0"
3737
// {x-release-please-end}
38+
}
39+
40+
tasks.register<Exec>("installAndLaunch") {
41+
description = "Installs and launches the demo app."
42+
group = "install"
43+
dependsOn(":maps-app:installDebug")
44+
commandLine("adb", "shell", "am", "start", "-n", "com.google.maps.android.compose/.MainActivity")
3845
}

gradle/libs.versions.toml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
[versions]
2-
activitycompose = "1.12.1"
3-
agp = "8.13.1"
2+
activitycompose = "1.12.2"
3+
agp = "8.13.2"
44
androidCore = "1.7.0"
55
androidx-core = "1.17.0"
66
androidxtest = "1.7.0"
7-
compose-bom = "2025.12.00"
7+
androidx-startup = "1.2.0"
8+
compose-bom = "2026.01.00"
89
dokka = "2.1.0"
910
espresso = "3.7.0"
10-
gradleMavenPublishPlugin = "0.35.0"
11+
gradleMavenPublishPlugin = "0.36.0"
1112
jacoco-plugin = "0.2.1"
1213
junit = "4.13.2"
1314
junitktx = "1.3.0"
14-
kotlin = "2.2.21"
15+
kotlin = "2.3.0"
1516
kotlinxCoroutines = "1.10.2"
1617
leakcanaryAndroid = "2.14"
1718
mapsecrets = "2.0.1"
18-
mapsktx = "5.2.1"
19+
mapsktx = "5.2.2"
1920
material3 = "1.4.0"
2021
materialIconsExtendedAndroid = "1.7.8"
21-
mockk = "1.14.6"
22-
mockkAndroid = "1.14.6"
22+
mockk = "1.14.7"
23+
mockkAndroid = "1.14.7"
2324
org-jacoco-core = "0.8.14"
24-
screenshot = "0.0.1-alpha12"
25+
screenshot = "0.0.1-alpha13"
2526
constraintlayout = "2.2.1"
2627
material = "1.13.0"
27-
robolectric = "4.16"
28+
robolectric = "4.16.1"
2829
truth = "1.4.5"
2930

3031
[libraries]
@@ -40,6 +41,7 @@ androidx-compose-ui-preview-tooling = { module = "androidx.compose.ui:ui-tooling
4041
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
4142
androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
4243
androidx-test-compose-ui = { module = "androidx.compose.ui:ui-test-junit4" }
44+
androidx-startup-runtime = { module = "androidx.startup:startup-runtime", version.ref = "androidx-startup" }
4345
androidx-test-core = { module = "androidx.test:core", version.ref = "androidCore" }
4446
androidx-test-espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
4547
androidx-test-junit-ktx = { module = "androidx.test.ext:junit-ktx", version.ref = "junitktx" }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-sdk tools:overrideLibrary="io.mockk.android,io.mockk.proxy.android" />
6+
</manifest>

maps-app/src/androidTest/java/com/google/maps/android/compose/GoogleMapViewTests.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ import com.google.android.gms.maps.model.CameraPosition
3131
import com.google.android.gms.maps.model.LatLng
3232
import com.google.common.truth.Truth.assertThat
3333
import com.google.maps.android.compose.LatLngSubject.Companion.assertThat
34-
import com.google.maps.android.compose.internal.DefaultGoogleMapsInitializer
35-
import com.google.maps.android.compose.internal.InitializationState
3634
import kotlinx.coroutines.runBlocking
3735
import org.junit.Before
3836
import org.junit.Rule
@@ -54,13 +52,7 @@ class GoogleMapViewTests {
5452
val countDownLatch = CountDownLatch(1)
5553

5654
val appContext: Context = InstrumentationRegistry.getInstrumentation().targetContext
57-
val googleMapsInitializer = DefaultGoogleMapsInitializer()
5855

59-
runBlocking {
60-
googleMapsInitializer.initialize(appContext)
61-
}
62-
63-
assertThat(googleMapsInitializer.state.value).isEqualTo(InitializationState.SUCCESS)
6456

6557
composeTestRule.setContent {
6658
GoogleMapView(

maps-app/src/androidTest/java/com/google/maps/android/compose/ScaleBarTests.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ package com.google.maps.android.compose
1616

1717
import android.graphics.Point
1818
import androidx.compose.foundation.layout.Box
19+
import androidx.compose.ui.platform.LocalDensity
1920
import androidx.compose.ui.test.junit4.createComposeRule
2021
import androidx.compose.ui.test.onNodeWithText
22+
import androidx.compose.ui.unit.Density
2123
import androidx.compose.ui.unit.dp
2224
import com.google.android.gms.maps.model.CameraPosition
2325
import com.google.android.gms.maps.model.LatLng
@@ -44,6 +46,7 @@ class ScaleBarTests {
4446
val composeTestRule = createComposeRule()
4547

4648
private lateinit var cameraPositionState: CameraPositionState
49+
private lateinit var density: Density
4750

4851
private fun initScaleBar(initialZoom: Float, initialPosition: LatLng) {
4952
check(hasValidApiKey) { "Maps API key not specified" }
@@ -55,6 +58,7 @@ class ScaleBarTests {
5558
)
5659

5760
composeTestRule.setContent {
61+
density = LocalDensity.current
5862
Box {
5963
GoogleMap(
6064
cameraPositionState = cameraPositionState,
@@ -87,7 +91,9 @@ class ScaleBarTests {
8791
val projection = cameraPositionState.projection
8892
projection?.let { proj ->
8993
val widthInDp = 65.dp
90-
val widthInPixels = widthInDp.value.toInt()
94+
val widthInPixels = with(density) {
95+
widthInDp.toPx().toInt()
96+
}
9197

9298
val upperLeftLatLng = proj.fromScreenLocation(Point(0, 0))
9399
val upperRightLatLng = proj.fromScreenLocation(Point(0, widthInPixels))

maps-app/src/androidTest/java/com/google/maps/android/compose/internal/GoogleMapsInitializerTest.kt

Lines changed: 0 additions & 235 deletions
This file was deleted.

0 commit comments

Comments
 (0)