Skip to content

Commit cdb28ce

Browse files
committed
feat: update to maps 20.0.0 and add usage attribution
1 parent 24618f9 commit cdb28ce

4 files changed

Lines changed: 101 additions & 12 deletions

File tree

gradle/libs.versions.toml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
[versions]
22
compileSdk = "36"
33
targetSdk = "36"
4-
minimumSdk = "21"
4+
minimumSdk = "23"
55

66
appcompat = "1.7.1"
77
dokka-gradle-plugin = "2.1.0"
8-
gradle = "8.13.1"
8+
gradle = "8.13.2"
99
jacoco-android = "0.2.1"
1010
lifecycle-extensions = "2.2.0"
11-
lifecycle-viewmodel-ktx = "2.9.4"
11+
lifecycle-viewmodel-ktx = "2.10.0"
12+
startup-runtime = "1.2.0"
1213
kotlin = "2.2.21"
1314
kotlinx-coroutines = "1.10.2"
1415
junit = "4.13.2"
15-
mockito-core = "5.20.0"
16+
mockito-core = "5.21.0"
1617
secrets-gradle-plugin = "2.0.1"
1718
truth = "1.4.5"
18-
play-services-maps = "19.2.0"
19+
play-services-maps = "20.0.0"
1920
core-ktx = "1.17.0"
20-
robolectric = "4.16"
21+
robolectric = "4.16.1"
2122
kxml2 = "2.3.0"
22-
mockk = "1.14.6"
23-
lint = "31.13.1"
23+
mockk = "1.14.7"
24+
lint = "32.0.0"
2425
org-jacoco-core = "0.8.14"
2526
material = "1.13.0"
26-
gradleMavenPublishPlugin = "0.35.0"
27+
gradleMavenPublishPlugin = "0.36.0"
2728

2829
[libraries]
2930
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
@@ -34,6 +35,7 @@ kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", v
3435
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
3536
lifecycle-extensions = { module = "androidx.lifecycle:lifecycle-extensions", version.ref = "lifecycle-extensions" }
3637
lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle-viewmodel-ktx" }
38+
startup-runtime = { module = "androidx.startup:startup-runtime", version.ref = "startup-runtime" }
3739
kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
3840
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
3941
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }

library/build.gradle.kts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ android {
2727
}
2828
defaultConfig {
2929
compileSdk = libs.versions.compileSdk.get().toInt()
30-
minSdk = 21
30+
minSdk = libs.versions.minimumSdk.get().toInt()
3131
testOptions.targetSdk = libs.versions.targetSdk.get().toInt()
3232
consumerProguardFiles("consumer-rules.pro")
3333
}
@@ -60,13 +60,15 @@ android {
6060
unitTests.isReturnDefaultValues = true
6161
}
6262
namespace = "com.google.maps.android"
63+
sourceSets["main"].java.srcDir("build/generated/source/artifactId")
6364
}
6465

6566
dependencies {
6667
api(libs.play.services.maps)
6768
implementation(libs.kotlinx.coroutines.android)
6869
implementation(libs.appcompat)
6970
implementation(libs.core.ktx)
71+
implementation(libs.startup.runtime)
7072
lintPublish(project(":lint-checks"))
7173
testImplementation(libs.junit)
7274
testImplementation(libs.robolectric)
@@ -89,3 +91,39 @@ tasks.register("instrumentTest") {
8991
if (System.getenv("JITPACK") != null) {
9092
apply(plugin = "maven")
9193
}
94+
95+
// START: Attribution ID Generation Logic
96+
val attributionId = "gmp_git_androidmapsutils_v$version"
97+
98+
val generateArtifactIdFile = tasks.register("generateArtifactIdFile") {
99+
description = "Generates an AttributionId object from the project version."
100+
group = "build"
101+
102+
val outputDir = layout.buildDirectory.dir("generated/source/artifactId")
103+
val packageName = "com.google.maps.android.utils.meta"
104+
val packagePath = packageName.replace('.', '/')
105+
val outputFile = outputDir.get().file("$packagePath/ArtifactId.kt").asFile
106+
107+
outputs.file(outputFile)
108+
109+
doLast {
110+
outputFile.parentFile.mkdirs()
111+
outputFile.writeText(
112+
"""
113+
package $packageName
114+
115+
/**
116+
* Automatically generated object containing the library's attribution ID.
117+
* This is used to track library usage for analytics.
118+
*/
119+
public object AttributionId {
120+
public const val VALUE: String = "$attributionId"
121+
}
122+
""".trimIndent()
123+
)
124+
}
125+
}
126+
127+
tasks.named("preBuild") {
128+
dependsOn(generateArtifactIdFile)
129+
}

library/src/main/AndroidManifest.xml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
3-
Copyright 2024 Google LLC
3+
Copyright 2025 Google LLC
44
55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -15,12 +15,23 @@
1515
limitations under the License.
1616
-->
1717

18-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
18+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
19+
xmlns:tools="http://schemas.android.com/tools">
1920
<!-- https://groups.google.com/group/adt-dev/browse_thread/thread/c059c0380998092b/6720093fb40fdaf9 -->
2021
<application>
2122
<meta-data
2223
android:name="com.google.android.gms.version"
2324
android:value="@integer/google_play_services_version" />
2425

26+
<provider
27+
android:name="androidx.startup.InitializationProvider"
28+
android:authorities="${applicationId}.androidx-startup"
29+
android:exported="false"
30+
tools:node="merge">
31+
32+
<meta-data
33+
android:name="com.google.maps.android.utils.attribution.AttributionIdInitializer"
34+
android:value="androidx.startup" />
35+
</provider>
2536
</application>
2637
</manifest>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.maps.android.utils.attribution
18+
19+
import android.content.Context
20+
import androidx.startup.Initializer
21+
import com.google.android.gms.maps.MapsApiSettings
22+
import com.google.maps.android.utils.meta.AttributionId
23+
24+
/**
25+
* Initializes the AttributionId at application startup.
26+
*/
27+
internal class AttributionIdInitializer : Initializer<Unit> {
28+
override fun create(context: Context) {
29+
MapsApiSettings.addInternalUsageAttributionId(
30+
/* context = */ context,
31+
/* internalUsageAttributionId = */ AttributionId.VALUE
32+
)
33+
}
34+
35+
override fun dependencies(): List<Class<out Initializer<*>>> {
36+
return emptyList()
37+
}
38+
}

0 commit comments

Comments
 (0)