From 15aa494f110ae8d977b73605888ecec9a63e52c7 Mon Sep 17 00:00:00 2001 From: dkhawk <107309+dkhawk@users.noreply.github.com> Date: Wed, 11 Mar 2026 17:42:27 -0600 Subject: [PATCH 1/6] chore: modernize build and update Places SDK to v5 This commit includes several modernization efforts and fixes: - Migrated build scripts from Groovy to Kotlin DSL (build.gradle.kts) - Implemented Version Catalogs (gradle/libs.versions.toml) for dependency management - Updated Java target to 17 - Cleaned up 16 unused dependencies (androidx, transport, joda-time, kotlin-reflect) - Updated Places SDK integration for v5 compatibility (Place.Field.DISPLAY_NAME, place.location, Places.initializeWithNewPlacesApiEnabled) - Rewrote README with clear setup instructions and added custom installAndLaunch gradle task - Ignored BOB_DATA directory --- .gitignore | 2 + navigation-sample/.vscode/settings.json | 3 + navigation-sample/README.md | 59 +++++--- navigation-sample/app/build.gradle | 134 ------------------ navigation-sample/app/build.gradle.kts | 124 ++++++++++++++++ .../navigationapidemo/NavFragmentActivity.kt | 2 +- .../navigationapidemo/NavViewActivity.kt | 2 +- .../navigationapidemo/PlacePickerActivity.kt | 2 +- .../navigationapidemo/SplashScreenActivity.kt | 2 +- .../SwappingMapAndNavActivity.kt | 2 +- .../{build.gradle => build.gradle.kts} | 33 ++--- navigation-sample/gradle/libs.versions.toml | 45 ++++++ .../gradle/wrapper/gradle-wrapper.properties | 2 +- navigation-sample/settings.gradle | 16 --- navigation-sample/settings.gradle.kts | 25 ++++ 15 files changed, 251 insertions(+), 202 deletions(-) create mode 100644 navigation-sample/.vscode/settings.json delete mode 100644 navigation-sample/app/build.gradle create mode 100644 navigation-sample/app/build.gradle.kts rename navigation-sample/{build.gradle => build.gradle.kts} (57%) mode change 100755 => 100644 create mode 100644 navigation-sample/gradle/libs.versions.toml delete mode 100755 navigation-sample/settings.gradle create mode 100644 navigation-sample/settings.gradle.kts diff --git a/.gitignore b/.gitignore index 4acd0f0..1a00777 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ build/ .gradle/ local.properties .idea/ +navigation-sample/secrets.properties +BOB_DATA/ diff --git a/navigation-sample/.vscode/settings.json b/navigation-sample/.vscode/settings.json new file mode 100644 index 0000000..1133129 --- /dev/null +++ b/navigation-sample/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic" +} \ No newline at end of file diff --git a/navigation-sample/README.md b/navigation-sample/README.md index f830f8a..c08f4b2 100755 --- a/navigation-sample/README.md +++ b/navigation-sample/README.md @@ -1,30 +1,47 @@ # Google Navigation SDK Sample Project -This sample project provides an example of using the Google Navigation SDK in an -Android Studio project. +This sample project provides runnable examples demonstrating how to integrate the **Google Navigation SDK for Android** and the **Google Places SDK for Android (New)**. -## Installation +## Prerequisites -- Open this sample app in Android Studio. +Before building and running the sample app, you need a Google Cloud Project with the correct APIs enabled and an API key with billing configured. -- This demo app is compatible with a range of supported Navigation SDK - versions, as indicated by the name of the containing .zip file in Google - Drive. +### 1. Enable Required APIs +Go to the [Google Cloud Console](https://console.cloud.google.com/) and enable the following APIs for your project: +* **Navigation SDK for Android** +* **Places API (New)** (Required for the location search features) +* **Maps SDK for Android** (Often required alongside Navigation) -- A default compatible version number has been supplied in the app-level - `build.gradle` file under the variable named `navSdkVersion`. Make sure to - update that variable's value to the version of NavSDK you'd like to test. +### 2. Configure Your API Key +1. Generate an API Key in the Google Cloud Console (APIs & Services > Credentials). +2. For security, restrict this API key to your Android app's signing certificate and package name (`com.example.navigationapidemo`). +3. Create a file named `secrets.properties` in the root directory of this project (the folder containing `build.gradle.kts` and `settings.gradle.kts`). +4. Add your API key to `secrets.properties` using the following format: + ```properties + MAPS_API_KEY=YOUR_API_KEY + ``` + *Note: This file is ignored by Git, ensuring your API key is not accidentally committed to version control. The app includes a `local.defaults.properties` fallback if the secrets file is missing.* -- Update the YOUR_API_KEY value in the local.defaults.properties to your own - API key from a project that has been authorized to use the Google Navigation - SDK. This API key must also have access to the Google Places API enabled in - order to be able to search for places in the sample application. - See [instructions](https://developers.google.com/maps/documentation/android-sdk/start#get-key) - for how to get your own key and learn more about - [Secrets Gradle plugin](https://developers.google.com/maps/documentation/android-sdk/secrets-gradle-plugin) - to keep the key out of version control systems. +## Building and Running -- In the **Gradle Scripts folder**, open the `gradle.properties` file and add - the following if not already present: `android.useAndroidX=true` +You can build and run this sample project using either Android Studio or the command line. -- Build and run the sample application. +### Using Android Studio +1. **Open the project in Android Studio.** Let Gradle sync the dependencies downloaded from the `gradle/libs.versions.toml` version catalog. +2. Select an emulator or connected physical device. +3. Click **Run** to build and launch the application. + +### Using the Command Line +Ensure you have a device connected or an emulator running (verify with `adb devices`). Run the following command from the root of the project to cleanly build, install, and launch the app in one step: + +```bash +./gradlew clean :app:installAndLaunch +``` + +Alternatively, to only build the APK without installing it: +```bash +./gradlew assembleDebug +``` + +## Modifying Dependencies +This project uses Gradle Version Catalogs. To update the Navigation SDK or Places SDK to a newer version, modify the version strings declared in `gradle/libs.versions.toml`. diff --git a/navigation-sample/app/build.gradle b/navigation-sample/app/build.gradle deleted file mode 100644 index b017abb..0000000 --- a/navigation-sample/app/build.gradle +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2024 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' -apply plugin: 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' - -ext { - androidxLifecycleVersion = "2.6.2" - glideVersion = "4.13.2" - navSdkVersion = "7.0.0" -} - -android { - namespace 'com.example.navigationapidemo' - compileSdk 36 - - buildFeatures { - buildConfig true - } - - defaultConfig { - applicationId "com.example.navigationapidemo" - // Navigation SDK supports a minimum of SDK 24. - minSdkVersion 24 - targetSdkVersion 36 - versionCode 1 - versionName "1.0" - // Set this to the languages you actually use, otherwise you'll include resource strings - // for all Navigation SDK supported languages. - resConfigs "en" - } - - dexOptions { - // This increases the amount of memory available to the dexer. This is required to build - // apps using the Navigation SDK. - javaMaxHeapSize "4g" - } - buildTypes { - // Run proguard. Note that the Navigation SDK includes its own proguard config, and that - // will be included transitively by depending on the Navigation SDK. - // If the proguard step takes too long, consider enabling multidex for development work - // instead. - all { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - compileOptions { - coreLibraryDesugaringEnabled true - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } - - kotlinOptions { - jvmTarget = "11" - } -} - -// This tells gradle where to look to find additional libraries -repositories { - google() -} - -dependencies { - // Include the Google Navigation SDK. - // Note: remember to exclude Google play service Maps SDK from your transitive - // dependencies to avoid duplicate copies of the Google Maps SDK. - api "com.google.android.libraries.navigation:navigation:${navSdkVersion}" - - // Add: android.useDeprecatedNdk=true - // to local.properties. - api "org.chromium.net:cronet-fallback:119.6045.31" - // Optional for Cronet users: - // api "org.chromium.net:cronet-api:69.3497.100" - - // Add LeakCanary to debugImplementation because LeakCanary should only run - // in debug builds. - debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14' - - // And dependencies. - api "androidx.appcompat:appcompat:1.7.1" - api "androidx.cardview:cardview:1.0.0" - api "androidx.constraintlayout:constraintlayout:2.1.4" - api "androidx.customview:customview:1.1.0" - api "androidx.legacy:legacy-support-v4:1.0.0" - api "androidx.lifecycle:lifecycle-common-java8:${androidxLifecycleVersion}" - api "androidx.lifecycle:lifecycle-process:${androidxLifecycleVersion}" - api "androidx.mediarouter:mediarouter:1.4.0" - api "androidx.preference:preference:1.2.1" - api "androidx.recyclerview:recyclerview:1.3.1" - api "androidx.tracing:tracing:1.1.0" - api "androidx.transition:transition:1.5.1" - api "androidx.viewpager2:viewpager2:1.0.0" - api "androidx.window:window:1.1.0" - api "com.github.bumptech.glide:glide:${glideVersion}" - api "com.google.android.datatransport:transport-api:3.0.0" - api "com.google.android.datatransport:transport-backend-cct:3.1.4" - api "com.google.android.datatransport:transport-runtime:3.1.4" - api "joda-time:joda-time:2.10.14" - // Also include the Google Places SDK, which is used by this example, but - // isn't required by the Navigation SDK. - api "com.google.android.libraries.places:places:4.0.0" - api "com.google.android.material:material:1.12.0" - api 'org.jetbrains.kotlin:kotlin-reflect:2.1.10' - api 'org.jetbrains.kotlin:kotlin-stdlib:2.1.10' - api 'com.google.guava:guava:31.0.1-android' - - annotationProcessor "androidx.annotation:annotation:1.7.0" - annotationProcessor "com.github.bumptech.glide:compiler:${glideVersion}" - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.0.4' -} - -secrets { - // To add your Maps API key to this project: - // 1. Open the root project's local.properties file - // 2. Add this line, where YOUR_API_KEY is your API key: - // MAPS_API_KEY=YOUR_API_KEY - defaultPropertiesFileName 'local.defaults.properties' -} diff --git a/navigation-sample/app/build.gradle.kts b/navigation-sample/app/build.gradle.kts new file mode 100644 index 0000000..dfcc3f5 --- /dev/null +++ b/navigation-sample/app/build.gradle.kts @@ -0,0 +1,124 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.maps.secrets) +} + +android { + namespace = "com.example.navigationapidemo" + compileSdk = 36 + + buildFeatures { + buildConfig = true + } + + defaultConfig { + applicationId = "com.example.navigationapidemo" + // Navigation SDK supports a minimum of SDK 24. + minSdk = 24 + targetSdk = 36 + versionCode = 1 + versionName = "1.0" + } + + androidResources { + // Set this to the languages you actually use, otherwise you'll include resource strings + // for all Navigation SDK supported languages. + localeFilters += "en" + } + + buildTypes { + // Run proguard. Note that the Navigation SDK includes its own proguard config, and that + // will be included transitively by depending on the Navigation SDK. + // If the proguard step takes too long, consider enabling multidex for development work + // instead. + getByName("release") { + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + getByName("debug") { + isMinifyEnabled = false + } + } + + compileOptions { + isCoreLibraryDesugaringEnabled = true + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } +} + +kotlin { + jvmToolchain(17) +} + +dependencies { + // Include the Google Navigation SDK. + // Note: remember to exclude Google play service Maps SDK from your transitive + // dependencies to avoid duplicate copies of the Google Maps SDK. + implementation(libs.google.maps.navigation) + + // Add: android.useDeprecatedNdk=true + // to local.properties. + implementation(libs.cronet.fallback) + // Optional for Cronet users: + // implementation "org.chromium.net:cronet-api:69.3497.100" + + // Add LeakCanary to debugImplementation because LeakCanary should only run + // in debug builds. + debugImplementation(libs.leakcanary) + + // And dependencies. + implementation(libs.androidx.appcompat) + implementation(libs.androidx.constraintlayout) + + implementation(libs.glide) + + // Also include the Google Places SDK, which is used by this example, but + // isn't required by the Navigation SDK. + implementation(libs.google.places) + implementation(libs.google.material) + + implementation(libs.kotlin.stdlib) + implementation(libs.guava) + + annotationProcessor(libs.androidx.annotation) + annotationProcessor(libs.glide.compiler) + coreLibraryDesugaring(libs.desugar.jdk.libs) +} + +secrets { + // To add your Maps API key to this project: + // 1. Create a secrets.properties file in the root project directory + // 2. Add this line, where YOUR_API_KEY is your API key: + // MAPS_API_KEY=YOUR_API_KEY + propertiesFileName = "secrets.properties" + defaultPropertiesFileName = "local.defaults.properties" +} + +tasks.register("installAndLaunch") { + description = "Installs and launches the debug build on a connected device or emulator." + group = "running" + dependsOn("installDebug") + doLast { + exec { + commandLine("adb", "shell", "am", "start", "-n", "com.example.navigationapidemo/.SplashScreenActivity") + } + } +} diff --git a/navigation-sample/app/src/main/java/com/example/navigationapidemo/NavFragmentActivity.kt b/navigation-sample/app/src/main/java/com/example/navigationapidemo/NavFragmentActivity.kt index 69a83ca..80fbf0e 100755 --- a/navigation-sample/app/src/main/java/com/example/navigationapidemo/NavFragmentActivity.kt +++ b/navigation-sample/app/src/main/java/com/example/navigationapidemo/NavFragmentActivity.kt @@ -209,7 +209,7 @@ class NavFragmentActivity : AppCompatActivity() { // An example of setting a destination via Lat-Lng. // Note: Setting LatLng destinations can result in poor routing quality/ETA calculation. // Wherever possible you should use a Place ID to describe the destination accurately. - place.latLng?.let { Waypoint.builder().setLatLng(it.latitude, it.longitude).build() } + place.location?.let { Waypoint.builder().setLatLng(it.latitude, it.longitude).build() } } else { // Set a destination by using a Place ID (the recommended method) try { diff --git a/navigation-sample/app/src/main/java/com/example/navigationapidemo/NavViewActivity.kt b/navigation-sample/app/src/main/java/com/example/navigationapidemo/NavViewActivity.kt index 2df6ab0..128e521 100755 --- a/navigation-sample/app/src/main/java/com/example/navigationapidemo/NavViewActivity.kt +++ b/navigation-sample/app/src/main/java/com/example/navigationapidemo/NavViewActivity.kt @@ -211,7 +211,7 @@ class NavViewActivity : AppCompatActivity() { // An example of setting a destination via Lat-Lng. // Note: Setting LatLng destinations can result in poor routing quality/ETA calculation. // Wherever possible you should use a Place ID to describe the destination accurately. - place.latLng?.let { Waypoint.builder().setLatLng(it.latitude, it.longitude).build() } + place.location?.let { Waypoint.builder().setLatLng(it.latitude, it.longitude).build() } } else { // Set a destination by using a Place ID (the recommended method) try { diff --git a/navigation-sample/app/src/main/java/com/example/navigationapidemo/PlacePickerActivity.kt b/navigation-sample/app/src/main/java/com/example/navigationapidemo/PlacePickerActivity.kt index e8d0f38..c7871f2 100755 --- a/navigation-sample/app/src/main/java/com/example/navigationapidemo/PlacePickerActivity.kt +++ b/navigation-sample/app/src/main/java/com/example/navigationapidemo/PlacePickerActivity.kt @@ -46,7 +46,7 @@ class PlacePickerActivity : AppCompatActivity() { // Specify the types of place data to return. autocompleteFragment?.setPlaceFields( - Arrays.asList(Place.Field.ID, Place.Field.NAME, Place.Field.LAT_LNG, Place.Field.TYPES) + Arrays.asList(Place.Field.ID, Place.Field.DISPLAY_NAME, Place.Field.LOCATION, Place.Field.TYPES) ) // Set up a PlaceSelectionListener to handle the response. diff --git a/navigation-sample/app/src/main/java/com/example/navigationapidemo/SplashScreenActivity.kt b/navigation-sample/app/src/main/java/com/example/navigationapidemo/SplashScreenActivity.kt index 6e6fafd..4a300e3 100755 --- a/navigation-sample/app/src/main/java/com/example/navigationapidemo/SplashScreenActivity.kt +++ b/navigation-sample/app/src/main/java/com/example/navigationapidemo/SplashScreenActivity.kt @@ -37,7 +37,7 @@ import java.util.concurrent.TimeUnit class SplashScreenActivity : AppCompatActivity() { override fun onCreate(bundle: Bundle?) { super.onCreate(bundle) - Places.initialize(applicationContext, getApiKeyFromMetaData()) + Places.initializeWithNewPlacesApiEnabled(applicationContext, getApiKeyFromMetaData()) setContentView(R.layout.activity_splash_screen) // Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android diff --git a/navigation-sample/app/src/main/java/com/example/navigationapidemo/SwappingMapAndNavActivity.kt b/navigation-sample/app/src/main/java/com/example/navigationapidemo/SwappingMapAndNavActivity.kt index 91d50ca..1166123 100755 --- a/navigation-sample/app/src/main/java/com/example/navigationapidemo/SwappingMapAndNavActivity.kt +++ b/navigation-sample/app/src/main/java/com/example/navigationapidemo/SwappingMapAndNavActivity.kt @@ -139,7 +139,7 @@ class SwappingMapAndNavActivity : AppCompatActivity() { // Show an example of setting a destination Lat-Lng // Note: Setting LatLng destinations can result in poor routing quality/ETA calculation. // Wherever possible you should use a Place ID to describe the destination accurately. - place.latLng?.let { Waypoint.builder().setLatLng(it.latitude, it.longitude).build() } + place.location?.let { Waypoint.builder().setLatLng(it.latitude, it.longitude).build() } } else { // Set a destination by using a Place ID (the recommended method) try { diff --git a/navigation-sample/build.gradle b/navigation-sample/build.gradle.kts old mode 100755 new mode 100644 similarity index 57% rename from navigation-sample/build.gradle rename to navigation-sample/build.gradle.kts index 29fd0fa..9d6078a --- a/navigation-sample/build.gradle +++ b/navigation-sample/build.gradle.kts @@ -15,40 +15,23 @@ */ // Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - mavenCentral() - google() - } - dependencies { - classpath 'com.android.tools.build:gradle:8.7.3' - classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - +@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed plugins { - id 'org.jetbrains.kotlin.android' version '2.1.10' apply false + alias(libs.plugins.android.application) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.maps.secrets) apply false } allprojects { - repositories { - mavenCentral() - } // Required: you must exclude the Google play service Maps SDK from // your transitive dependencies. This is to ensure there won't be // multiple copies of Google Maps SDK in your binary, as navigation SDK // already bundles the Google Maps SDK. - configurations { - implementation { - exclude group: 'com.google.android.gms', module: 'play-services-maps' - } + configurations.all { + exclude(group = "com.google.android.gms", module = "play-services-maps") } } -task clean(type: Delete) { - delete rootProject.buildDir +tasks.register("clean") { + delete(layout.buildDirectory) } diff --git a/navigation-sample/gradle/libs.versions.toml b/navigation-sample/gradle/libs.versions.toml new file mode 100644 index 0000000..a50a101 --- /dev/null +++ b/navigation-sample/gradle/libs.versions.toml @@ -0,0 +1,45 @@ +[versions] +agp = "8.13.2" +kotlin = "2.3.10" +secretsPlugin = "2.0.1" + +androidxLifecycle = "2.10.0" +glide = "5.0.5" +navSdk = "7.4.0" + +appcompat = "1.7.1" +constraintlayout = "2.2.1" + +cronetFallback = "143.7445.0" +leakcanary = "2.14" +places = "5.1.1" +material = "1.13.0" +guava = "33.5.0-android" + +annotation = "1.9.1" +desugarJdkLibs = "2.1.5" + +[libraries] +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } +androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } + +glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "glide" } +glide-compiler = { group = "com.github.bumptech.glide", name = "compiler", version.ref = "glide" } + +google-maps-navigation = { group = "com.google.android.libraries.navigation", name = "navigation", version.ref = "navSdk" } +google-places = { group = "com.google.android.libraries.places", name = "places", version.ref = "places" } + +google-material = { group = "com.google.android.material", name = "material", version.ref = "material" } +guava = { group = "com.google.guava", name = "guava", version.ref = "guava" } +kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } + +cronet-fallback = { group = "org.chromium.net", name = "cronet-fallback", version.ref = "cronetFallback" } +leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary" } + +androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" } +desugar-jdk-libs = { group = "com.android.tools", name = "desugar_jdk_libs_nio", version.ref = "desugarJdkLibs" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +maps-secrets = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secretsPlugin" } diff --git a/navigation-sample/gradle/wrapper/gradle-wrapper.properties b/navigation-sample/gradle/wrapper/gradle-wrapper.properties index df97d72..37f853b 100755 --- a/navigation-sample/gradle/wrapper/gradle-wrapper.properties +++ b/navigation-sample/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/navigation-sample/settings.gradle b/navigation-sample/settings.gradle deleted file mode 100755 index 46dcb06..0000000 --- a/navigation-sample/settings.gradle +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2024 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -include ':app' diff --git a/navigation-sample/settings.gradle.kts b/navigation-sample/settings.gradle.kts new file mode 100644 index 0000000..64d375c --- /dev/null +++ b/navigation-sample/settings.gradle.kts @@ -0,0 +1,25 @@ +pluginManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "navigation-sample" + +include(":app") From 4873469382a08629aebdb4a0ef314dccad5abf72 Mon Sep 17 00:00:00 2001 From: dkhawk <107309+dkhawk@users.noreply.github.com> Date: Wed, 11 Mar 2026 17:54:33 -0600 Subject: [PATCH 2/6] chore: modernize map-sample build - Migrated to Kotlin DSL (build.gradle.kts) and Version Catalog - Updated Java target to 17 - Cleaned up unused legacy dependencies - Upgraded Gradle wrapper to 8.13 - Overhauled map-sample README and added installAndLaunch target --- map-sample/README.md | 50 ++++--- map-sample/app/build.gradle | 134 ------------------ map-sample/app/build.gradle.kts | 121 ++++++++++++++++ map-sample/app/src/main/AndroidManifest.xml | 1 - map-sample/build.gradle | 54 ------- map-sample/build.gradle.kts | 27 ++++ map-sample/gradle/libs.versions.toml | 52 +++++++ .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../{settings.gradle => settings.gradle.kts} | 18 ++- 9 files changed, 250 insertions(+), 209 deletions(-) delete mode 100755 map-sample/app/build.gradle create mode 100644 map-sample/app/build.gradle.kts delete mode 100755 map-sample/build.gradle create mode 100644 map-sample/build.gradle.kts create mode 100644 map-sample/gradle/libs.versions.toml rename map-sample/{settings.gradle => settings.gradle.kts} (64%) mode change 100755 => 100644 diff --git a/map-sample/README.md b/map-sample/README.md index 9758165..3528b57 100755 --- a/map-sample/README.md +++ b/map-sample/README.md @@ -17,21 +17,35 @@ SupportNavigationFragment as part of the UI. This is to showcase that NavigationView supports the behaviors you may have come to expect from your previous usage of the public Maps APIs. -## Installation - -- Open this sample app in Android Studio. - -- This demo app is compatible with a range of supported Navigation SDK - versions, as indicated by the name of the containing .zip file in Google - Drive. - -- A default compatible version number has been supplied in the app-level - `build.gradle` file under the variable named `navSdkVersion`. Make sure to - update that variable's value to the version of NavSDK you'd like to test. - -- Update the YOUR_API_KEY value in local.defaults.properties to your own API - key that has been authorized to use the Google Navigation SDK. Visit - https://developers.google.com/maps/documentation/android-sdk/start#get-key - for instructions on how to get your own key. - -- Build and run the sample application. +## Installation & Setup + +### Prerequisites +Before running this app, ensure you have enabled the following **three** APIs in your Google Cloud Console for your project: +1. **Google Navigation SDK** +2. **Maps SDK for Android** +3. **Places API (New)** + +### 1. API Key Configuration +This project uses the [Secrets Gradle Plugin for Android](https://github.com/google/secrets-gradle-plugin) to safely inject your API key. + +1. Create a `secrets.properties` file in the `map-sample` directory (this file is gitignored). +2. Add your authorized Google Maps API key to this file: + ```properties + MAPS_API_KEY=AIzaSyYourKeyHere... + ``` + +### 2. Dependency Management +This app uses a modern Gradle Version Catalog (`gradle/libs.versions.toml`). To modify the Navigation SDK version or other library versions, update the corresponding `version` property within this file. + +### 3. Build and Run +You can open this project in **Android Studio** and click "Run", or use the command line directly: + +To compile the app from the terminal: +```bash +./gradlew clean assembleDebug +``` + +To automatically compile, install, and launch the demo app on a connected emulator or physical device, run: +```bash +./gradlew clean :app:installAndLaunch +``` diff --git a/map-sample/app/build.gradle b/map-sample/app/build.gradle deleted file mode 100755 index 7f05c48..0000000 --- a/map-sample/app/build.gradle +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2024 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: 'com.android.application' -apply plugin: 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' -apply plugin: 'org.jetbrains.kotlin.android' - -ext { - androidxLifecycleVersion = "2.6.2" - glideVersion = "4.13.2" - navSdkVersion = "7.0.0" -} - -android { - namespace 'com.example.mapdemo' - compileSdk 36 - - buildFeatures { - buildConfig true - } - - defaultConfig { - applicationId "com.example.mapdemo" - // Navigation SDK supports a minimum of SDK 24. - minSdkVersion 24 - // This example targets SDK 30 so that there's no need to explicitly include permissions - // flows in the app. - targetSdkVersion 36 - versionCode 1 - versionName "1.0" - // Set this to the languages you actually use, otherwise you'll include resource strings - // for all Navigation SDK supported languages. - resConfigs "en" - multiDexEnabled true - } - - dexOptions { - // This increases the amount of memory available to the dexer. This is required to build - // apps using the Navigation SDK. - javaMaxHeapSize "4g" - } - buildTypes { - // Run proguard. Note that the Navigation SDK includes its own proguard config, and that - // will be included transitively by depending on the Navigation SDK. - // If the proguard step takes too long, consider enabling multidex for development work - // instead. - all { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - compileOptions { - // Flag to enable support for the new language APIs - coreLibraryDesugaringEnabled true - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } - - kotlinOptions { - jvmTarget = "11" - } -} - -// This tells gradle where to look to find additional libraries. -repositories { - google() -} - -dependencies { - api "com.google.android.libraries.navigation:navigation:${navSdkVersion}" - - // Add: android.useDeprecatedNdk=true - // to local.properties. - api "org.chromium.net:cronet-fallback:119.6045.31" - // Optional for Cronet users: - // api "org.chromium.net:cronet-api:69.3497.100" - - // Add LeakCanary to debugImplementation because LeakCanary should only run - // in debug builds. - debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14' - - // And dependencies. - api "androidx.appcompat:appcompat:1.7.1" - api "androidx.cardview:cardview:1.0.0" - api "androidx.constraintlayout:constraintlayout:2.1.4" - api "androidx.customview:customview:1.1.0" - api "androidx.legacy:legacy-support-v4:1.0.0" - api "androidx.lifecycle:lifecycle-common-java8:${androidxLifecycleVersion}" - api "androidx.lifecycle:lifecycle-process:${androidxLifecycleVersion}" - api "androidx.mediarouter:mediarouter:1.4.0" - api "androidx.preference:preference:1.2.1" - api "androidx.recyclerview:recyclerview:1.3.1" - api "androidx.transition:transition:1.5.1" - api "androidx.viewpager2:viewpager2:1.0.0" - api "androidx.window:window:1.1.0" - api "com.github.bumptech.glide:glide:${glideVersion}" - api "com.google.android.datatransport:transport-api:3.0.0" - api "com.google.android.datatransport:transport-backend-cct:3.1.4" - api "com.google.android.datatransport:transport-runtime:3.1.4" - api "com.google.auto.value:auto-value-annotations:1.6.2" - annotationProcessor "com.google.auto.value:auto-value:1.6.2" - api 'com.google.errorprone:error_prone_annotations:2.11.0' - api 'com.google.guava:guava:31.0.1-android' - api "joda-time:joda-time:2.10.14" - api "com.google.android.material:material:1.12.0" - api 'org.jetbrains.kotlin:kotlin-reflect:2.1.10' - api 'org.jetbrains.kotlin:kotlin-stdlib:2.1.10' - - annotationProcessor "androidx.annotation:annotation:1.7.0" - annotationProcessor "com.github.bumptech.glide:compiler:${glideVersion}" - - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.0.4' -} - -secrets { - // To add your Maps API key to this project: - // 1. Open the root project's local.properties file - // 2. Add this line, where YOUR_API_KEY is your API key: - // MAPS_API_KEY=YOUR_API_KEY - defaultPropertiesFileName 'local.defaults.properties' -} diff --git a/map-sample/app/build.gradle.kts b/map-sample/app/build.gradle.kts new file mode 100644 index 0000000..d435b68 --- /dev/null +++ b/map-sample/app/build.gradle.kts @@ -0,0 +1,121 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.maps.secrets) +} + +android { + namespace = "com.example.mapdemo" + compileSdk = 36 + + buildFeatures { + buildConfig = true + } + + defaultConfig { + applicationId = "com.example.mapdemo" + // Navigation SDK supports a minimum of SDK 24. + minSdk = 24 + // This example targets SDK 30 so that there's no need to explicitly include permissions + // flows in the app. + targetSdk = 36 + versionCode = 1 + versionName = "1.0" + // Set this to the languages you actually use, otherwise you'll include resource strings + // for all Navigation SDK supported languages. + androidResources.localeFilters += "en" + multiDexEnabled = true + } + + buildTypes { + // Run proguard. Note that the Navigation SDK includes its own proguard config, and that + // will be included transitively by depending on the Navigation SDK. + // If the proguard step takes too long, consider enabling multidex for development work + // instead. + getByName("release") { + isMinifyEnabled = true + proguardFiles( + getDefaultProguardFile("proguard-android.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + // Flag to enable support for the new language APIs + isCoreLibraryDesugaringEnabled = true + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlin { + compilerOptions { + jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) + } + } +} + +dependencies { + implementation(libs.google.maps.navigation) + + // Add: android.useDeprecatedNdk=true + // to local.properties. + implementation(libs.cronet.fallback) + + // Add LeakCanary to debugImplementation because LeakCanary should only run + // in debug builds. + debugImplementation(libs.leakcanary) + + // And dependencies. + implementation(libs.androidx.appcompat) + implementation(libs.androidx.constraintlayout) + + implementation(libs.glide) + implementation(libs.auto.value.annotations) + annotationProcessor(libs.auto.value.processor) + implementation(libs.error.prone.annotations) + implementation(libs.guava) + implementation(libs.google.material) + implementation(libs.kotlin.stdlib) + + annotationProcessor(libs.androidx.annotation) + annotationProcessor(libs.glide.compiler) + + coreLibraryDesugaring(libs.desugar.jdk.libs) +} + +secrets { + // To add your Maps API key to this project: + // 1. Open the root project's secrets.properties file + // 2. Add this line, where YOUR_API_KEY is your API key: + // MAPS_API_KEY=YOUR_API_KEY + defaultPropertiesFileName = "local.defaults.properties" +} + +// Add a convenience target to build, install, and run the app +tasks.register("installAndLaunch") { + dependsOn("installDebug") + group = "execute" + description = "Installs and launches the debug APK on a connected device." + + doLast { + project.exec { + commandLine("adb", "shell", "monkey", "-p", "com.example.mapdemo", "-c", "android.intent.category.LAUNCHER", "1") + } + } +} diff --git a/map-sample/app/src/main/AndroidManifest.xml b/map-sample/app/src/main/AndroidManifest.xml index 11c9585..4ce8a54 100644 --- a/map-sample/app/src/main/AndroidManifest.xml +++ b/map-sample/app/src/main/AndroidManifest.xml @@ -16,7 +16,6 @@ --> diff --git a/map-sample/build.gradle b/map-sample/build.gradle deleted file mode 100755 index 29fd0fa..0000000 --- a/map-sample/build.gradle +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2024 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - mavenCentral() - google() - } - dependencies { - classpath 'com.android.tools.build:gradle:8.7.3' - classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -plugins { - id 'org.jetbrains.kotlin.android' version '2.1.10' apply false -} - -allprojects { - repositories { - mavenCentral() - } - // Required: you must exclude the Google play service Maps SDK from - // your transitive dependencies. This is to ensure there won't be - // multiple copies of Google Maps SDK in your binary, as navigation SDK - // already bundles the Google Maps SDK. - configurations { - implementation { - exclude group: 'com.google.android.gms', module: 'play-services-maps' - } - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/map-sample/build.gradle.kts b/map-sample/build.gradle.kts new file mode 100644 index 0000000..6b5b818 --- /dev/null +++ b/map-sample/build.gradle.kts @@ -0,0 +1,27 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +plugins { + alias(libs.plugins.android.application).apply(false) + alias(libs.plugins.kotlin.android).apply(false) + alias(libs.plugins.maps.secrets).apply(false) +} + +tasks.register("clean", Delete::class) { + delete(layout.buildDirectory) +} diff --git a/map-sample/gradle/libs.versions.toml b/map-sample/gradle/libs.versions.toml new file mode 100644 index 0000000..5811944 --- /dev/null +++ b/map-sample/gradle/libs.versions.toml @@ -0,0 +1,52 @@ +[versions] +agp = "8.13.2" +kotlin = "2.1.10" +secretsPlugin = "2.0.1" + +appcompat = "1.7.1" +constraintlayout = "2.2.1" + +cronetFallback = "119.6045.31" +leakcanary = "2.14" + +places = "5.1.1" +material = "1.12.0" +guava = "31.0.1-android" + +navSdk = "7.0.0" +glide = "4.13.2" +androidxLifecycle = "2.6.2" + +annotation = "1.7.0" +desugarJdkLibs = "2.0.4" +errorProneAnnotations = "2.11.0" +autoValue = "1.6.2" + +[libraries] +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } +androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } +androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" } + +glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "glide" } +glide-compiler = { group = "com.github.bumptech.glide", name = "compiler", version.ref = "glide" } + +google-maps-navigation = { group = "com.google.android.libraries.navigation", name = "navigation", version.ref = "navSdk" } +google-places = { group = "com.google.android.libraries.places", name = "places", version.ref = "places" } + +google-material = { group = "com.google.android.material", name = "material", version.ref = "material" } +guava = { group = "com.google.guava", name = "guava", version.ref = "guava" } + +kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } + +cronet-fallback = { group = "org.chromium.net", name = "cronet-fallback", version.ref = "cronetFallback" } +leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary" } + +desugar-jdk-libs = { group = "com.android.tools", name = "desugar_jdk_libs_nio", version.ref = "desugarJdkLibs" } +error-prone-annotations = { group = "com.google.errorprone", name = "error_prone_annotations", version.ref = "errorProneAnnotations" } +auto-value-annotations = { group = "com.google.auto.value", name = "auto-value-annotations", version.ref = "autoValue" } +auto-value-processor = { group = "com.google.auto.value", name = "auto-value", version.ref = "autoValue" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +maps-secrets = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secretsPlugin" } diff --git a/map-sample/gradle/wrapper/gradle-wrapper.properties b/map-sample/gradle/wrapper/gradle-wrapper.properties index df97d72..37f853b 100755 --- a/map-sample/gradle/wrapper/gradle-wrapper.properties +++ b/map-sample/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/map-sample/settings.gradle b/map-sample/settings.gradle.kts old mode 100755 new mode 100644 similarity index 64% rename from map-sample/settings.gradle rename to map-sample/settings.gradle.kts index 46dcb06..9633ebf --- a/map-sample/settings.gradle +++ b/map-sample/settings.gradle.kts @@ -13,4 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -include ':app' +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "map-sample" +include(":app") From 0b4b25dec8db0ae3938b09b7a4846a465368ca4b Mon Sep 17 00:00:00 2001 From: dkhawk <107309+dkhawk@users.noreply.github.com> Date: Wed, 11 Mar 2026 17:59:01 -0600 Subject: [PATCH 3/6] refactor: extract Places initialization to custom Application class - Created NavigationSampleApplication - Moved Places API initialization and metadata extraction logic from SplashScreenActivity to NavigationSampleApplication - Registered NavigationSampleApplication in AndroidManifest.xml --- .../app/src/main/AndroidManifest.xml | 1 + .../NavigationSampleApplication.kt | 45 +++++++++++++++++++ .../navigationapidemo/SplashScreenActivity.kt | 17 ------- 3 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 navigation-sample/app/src/main/java/com/example/navigationapidemo/NavigationSampleApplication.kt diff --git a/navigation-sample/app/src/main/AndroidManifest.xml b/navigation-sample/app/src/main/AndroidManifest.xml index e2e9f46..83f8763 100755 --- a/navigation-sample/app/src/main/AndroidManifest.xml +++ b/navigation-sample/app/src/main/AndroidManifest.xml @@ -22,6 +22,7 @@ Date: Wed, 11 Mar 2026 18:17:16 -0600 Subject: [PATCH 4/6] chore: clean up and alphabetize version catalogs - Sorted dependencies alphabetically - Synchronized versions between navigation-sample and map-sample - Corrected kotlin plugin version to 2.1.10 --- map-sample/gradle/libs.versions.toml | 49 ++++++++------------- navigation-sample/gradle/libs.versions.toml | 33 +++++--------- 2 files changed, 31 insertions(+), 51 deletions(-) diff --git a/map-sample/gradle/libs.versions.toml b/map-sample/gradle/libs.versions.toml index 5811944..84f2694 100644 --- a/map-sample/gradle/libs.versions.toml +++ b/map-sample/gradle/libs.versions.toml @@ -1,51 +1,40 @@ [versions] agp = "8.13.2" -kotlin = "2.1.10" -secretsPlugin = "2.0.1" - +androidxLifecycle = "2.10.0" +annotation = "1.9.1" appcompat = "1.7.1" +autoValue = "1.11.1" constraintlayout = "2.2.1" - -cronetFallback = "119.6045.31" +cronetFallback = "143.7445.0" +desugarJdkLibs = "2.1.5" +errorProneAnnotations = "2.48.0" +glide = "5.0.5" +guava = "33.5.0-android" +kotlin = "2.1.10" leakcanary = "2.14" - +material = "1.13.0" +navSdk = "7.4.0" places = "5.1.1" -material = "1.12.0" -guava = "31.0.1-android" - -navSdk = "7.0.0" -glide = "4.13.2" -androidxLifecycle = "2.6.2" - -annotation = "1.7.0" -desugarJdkLibs = "2.0.4" -errorProneAnnotations = "2.11.0" -autoValue = "1.6.2" +secretsPlugin = "2.0.1" [libraries] +androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } -androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" } - +auto-value-annotations = { group = "com.google.auto.value", name = "auto-value-annotations", version.ref = "autoValue" } +auto-value-processor = { group = "com.google.auto.value", name = "auto-value", version.ref = "autoValue" } +cronet-fallback = { group = "org.chromium.net", name = "cronet-fallback", version.ref = "cronetFallback" } +desugar-jdk-libs = { group = "com.android.tools", name = "desugar_jdk_libs_nio", version.ref = "desugarJdkLibs" } +error-prone-annotations = { group = "com.google.errorprone", name = "error_prone_annotations", version.ref = "errorProneAnnotations" } glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "glide" } glide-compiler = { group = "com.github.bumptech.glide", name = "compiler", version.ref = "glide" } - google-maps-navigation = { group = "com.google.android.libraries.navigation", name = "navigation", version.ref = "navSdk" } -google-places = { group = "com.google.android.libraries.places", name = "places", version.ref = "places" } - google-material = { group = "com.google.android.material", name = "material", version.ref = "material" } +google-places = { group = "com.google.android.libraries.places", name = "places", version.ref = "places" } guava = { group = "com.google.guava", name = "guava", version.ref = "guava" } - kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } - -cronet-fallback = { group = "org.chromium.net", name = "cronet-fallback", version.ref = "cronetFallback" } leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary" } -desugar-jdk-libs = { group = "com.android.tools", name = "desugar_jdk_libs_nio", version.ref = "desugarJdkLibs" } -error-prone-annotations = { group = "com.google.errorprone", name = "error_prone_annotations", version.ref = "errorProneAnnotations" } -auto-value-annotations = { group = "com.google.auto.value", name = "auto-value-annotations", version.ref = "autoValue" } -auto-value-processor = { group = "com.google.auto.value", name = "auto-value", version.ref = "autoValue" } - [plugins] android-application = { id = "com.android.application", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } diff --git a/navigation-sample/gradle/libs.versions.toml b/navigation-sample/gradle/libs.versions.toml index a50a101..eeeaa90 100644 --- a/navigation-sample/gradle/libs.versions.toml +++ b/navigation-sample/gradle/libs.versions.toml @@ -1,44 +1,35 @@ [versions] agp = "8.13.2" -kotlin = "2.3.10" -secretsPlugin = "2.0.1" - androidxLifecycle = "2.10.0" -glide = "5.0.5" -navSdk = "7.4.0" - +annotation = "1.9.1" appcompat = "1.7.1" constraintlayout = "2.2.1" - cronetFallback = "143.7445.0" +desugarJdkLibs = "2.1.5" +glide = "5.0.5" +guava = "33.5.0-android" +kotlin = "2.1.10" leakcanary = "2.14" -places = "5.1.1" material = "1.13.0" -guava = "33.5.0-android" - -annotation = "1.9.1" -desugarJdkLibs = "2.1.5" +navSdk = "7.4.0" +places = "5.1.1" +secretsPlugin = "2.0.1" [libraries] +androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } - +cronet-fallback = { group = "org.chromium.net", name = "cronet-fallback", version.ref = "cronetFallback" } +desugar-jdk-libs = { group = "com.android.tools", name = "desugar_jdk_libs_nio", version.ref = "desugarJdkLibs" } glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "glide" } glide-compiler = { group = "com.github.bumptech.glide", name = "compiler", version.ref = "glide" } - google-maps-navigation = { group = "com.google.android.libraries.navigation", name = "navigation", version.ref = "navSdk" } -google-places = { group = "com.google.android.libraries.places", name = "places", version.ref = "places" } - google-material = { group = "com.google.android.material", name = "material", version.ref = "material" } +google-places = { group = "com.google.android.libraries.places", name = "places", version.ref = "places" } guava = { group = "com.google.guava", name = "guava", version.ref = "guava" } kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } - -cronet-fallback = { group = "org.chromium.net", name = "cronet-fallback", version.ref = "cronetFallback" } leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary" } -androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" } -desugar-jdk-libs = { group = "com.android.tools", name = "desugar_jdk_libs_nio", version.ref = "desugarJdkLibs" } - [plugins] android-application = { id = "com.android.application", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } From a7ab3a01ffe11d8622847e1c9317fd2f30cedb11 Mon Sep 17 00:00:00 2001 From: dkhawk <107309+dkhawk@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:49:56 -0600 Subject: [PATCH 5/6] fix: exclude play-services-maps from android-maps-utils --- map-sample/gradle/libs.versions.toml | 3 --- navigation-sample/README.md | 5 ++--- navigation-sample/app/build.gradle.kts | 3 +++ navigation-sample/gradle/libs.versions.toml | 2 ++ 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/map-sample/gradle/libs.versions.toml b/map-sample/gradle/libs.versions.toml index 84f2694..0deb0a2 100644 --- a/map-sample/gradle/libs.versions.toml +++ b/map-sample/gradle/libs.versions.toml @@ -1,6 +1,5 @@ [versions] agp = "8.13.2" -androidxLifecycle = "2.10.0" annotation = "1.9.1" appcompat = "1.7.1" autoValue = "1.11.1" @@ -14,7 +13,6 @@ kotlin = "2.1.10" leakcanary = "2.14" material = "1.13.0" navSdk = "7.4.0" -places = "5.1.1" secretsPlugin = "2.0.1" [libraries] @@ -30,7 +28,6 @@ glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "gl glide-compiler = { group = "com.github.bumptech.glide", name = "compiler", version.ref = "glide" } google-maps-navigation = { group = "com.google.android.libraries.navigation", name = "navigation", version.ref = "navSdk" } google-material = { group = "com.google.android.material", name = "material", version.ref = "material" } -google-places = { group = "com.google.android.libraries.places", name = "places", version.ref = "places" } guava = { group = "com.google.guava", name = "guava", version.ref = "guava" } kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary" } diff --git a/navigation-sample/README.md b/navigation-sample/README.md index c08f4b2..3ada349 100755 --- a/navigation-sample/README.md +++ b/navigation-sample/README.md @@ -8,13 +8,12 @@ Before building and running the sample app, you need a Google Cloud Project with ### 1. Enable Required APIs Go to the [Google Cloud Console](https://console.cloud.google.com/) and enable the following APIs for your project: -* **Navigation SDK for Android** +* **Navigation SDK** * **Places API (New)** (Required for the location search features) -* **Maps SDK for Android** (Often required alongside Navigation) ### 2. Configure Your API Key 1. Generate an API Key in the Google Cloud Console (APIs & Services > Credentials). -2. For security, restrict this API key to your Android app's signing certificate and package name (`com.example.navigationapidemo`). +2. For security, we recommend restricting this API key to your Android app's signing certificate and package name (`com.example.navigationapidemo`). 3. Create a file named `secrets.properties` in the root directory of this project (the folder containing `build.gradle.kts` and `settings.gradle.kts`). 4. Add your API key to `secrets.properties` using the following format: ```properties diff --git a/navigation-sample/app/build.gradle.kts b/navigation-sample/app/build.gradle.kts index dfcc3f5..5c7a87e 100644 --- a/navigation-sample/app/build.gradle.kts +++ b/navigation-sample/app/build.gradle.kts @@ -94,6 +94,9 @@ dependencies { // isn't required by the Navigation SDK. implementation(libs.google.places) implementation(libs.google.material) + implementation(libs.google.maps.utils) { + exclude(group = "com.google.android.gms", module = "play-services-maps") + } implementation(libs.kotlin.stdlib) implementation(libs.guava) diff --git a/navigation-sample/gradle/libs.versions.toml b/navigation-sample/gradle/libs.versions.toml index eeeaa90..de8ae9d 100644 --- a/navigation-sample/gradle/libs.versions.toml +++ b/navigation-sample/gradle/libs.versions.toml @@ -11,6 +11,7 @@ guava = "33.5.0-android" kotlin = "2.1.10" leakcanary = "2.14" material = "1.13.0" +mapsUtils = "3.9.0" navSdk = "7.4.0" places = "5.1.1" secretsPlugin = "2.0.1" @@ -25,6 +26,7 @@ glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "gl glide-compiler = { group = "com.github.bumptech.glide", name = "compiler", version.ref = "glide" } google-maps-navigation = { group = "com.google.android.libraries.navigation", name = "navigation", version.ref = "navSdk" } google-material = { group = "com.google.android.material", name = "material", version.ref = "material" } +google-maps-utils = { group = "com.google.maps.android", name = "android-maps-utils", version.ref = "mapsUtils" } google-places = { group = "com.google.android.libraries.places", name = "places", version.ref = "places" } guava = { group = "com.google.guava", name = "guava", version.ref = "guava" } kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } From 973528020eaedfd2ccdc17f1403f1d144ea2c562 Mon Sep 17 00:00:00 2001 From: dkhawk <107309+dkhawk@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:50:36 -0600 Subject: [PATCH 6/6] docs: explain play-services-maps exclusion in build.gradle.kts --- navigation-sample/app/build.gradle.kts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/navigation-sample/app/build.gradle.kts b/navigation-sample/app/build.gradle.kts index 5c7a87e..6cb3ace 100644 --- a/navigation-sample/app/build.gradle.kts +++ b/navigation-sample/app/build.gradle.kts @@ -94,6 +94,9 @@ dependencies { // isn't required by the Navigation SDK. implementation(libs.google.places) implementation(libs.google.material) + // If you include the Maps Utils library, you must exclude the independent + // play-services-maps dependency, as the Navigation SDK provides its own + // bundled, compatible Map implementation. implementation(libs.google.maps.utils) { exclude(group = "com.google.android.gms", module = "play-services-maps") }