Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
build/
.gradle/
.kotlin/
local.properties
secrets.properties
.idea/
39 changes: 26 additions & 13 deletions map-sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,34 @@ 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
## Installation & Setup

- Open this sample app in Android Studio.
### Prerequisites
Before running this app, ensure you have enabled the following **two** APIs in your Google Cloud Console for your project:
1. **Google Navigation SDK**
2. **Maps SDK for Android**

- 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. 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.

- 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.
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...
```

- 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.
### 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.

- Build and run the sample application.
### 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
```
129 changes: 0 additions & 129 deletions map-sample/app/build.gradle

This file was deleted.

142 changes: 142 additions & 0 deletions map-sample/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* 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.
*/

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.maps.secrets)
}

android {
namespace = "com.example.mapdemo"
compileSdk = 37

buildFeatures {
buildConfig = true
}

defaultConfig {
applicationId = "com.example.mapdemo"
// Navigation SDK supports a minimum of SDK 24.
minSdk = 24
// This example targets SDK 37.
targetSdk = 37
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-optimize.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(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.cardview)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.customview)
implementation(libs.androidx.legacy.support.v4)
implementation(libs.androidx.lifecycle.common.java8)
implementation(libs.androidx.lifecycle.process)
implementation(libs.androidx.mediarouter)
implementation(libs.androidx.preference)
implementation(libs.androidx.recyclerview)
implementation(libs.androidx.transition)
implementation(libs.androidx.viewpager2)
implementation(libs.androidx.window)

implementation(libs.glide)
implementation(libs.datatransport.api)
implementation(libs.datatransport.backend.cct)
implementation(libs.datatransport.runtime)
implementation(libs.auto.value.annotations)
annotationProcessor(libs.auto.value.processor)
implementation(libs.error.prone.annotations)
implementation(libs.guava)
implementation(libs.joda.time)
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. Create a secrets.properties file in the map-sample 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"
}

// 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 {
ProcessBuilder(
"adb",
"shell",
"am",
"start",
"-n",
"com.example.mapdemo/.MainActivity"
).inheritIO().start().waitFor()
}
}
54 changes: 54 additions & 0 deletions map-sample/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2026 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.

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/<username>/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

#glide start
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
#glide end

#okhttp start
# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**

# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*

# OkHttp platform used only on JVM and when Conscrypt dependency is available.
-dontwarn okhttp3.internal.platform.ConscryptPlatform
#okhttp end
Loading
Loading