Skip to content
Open
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
Expand Up @@ -2,3 +2,5 @@ build/
.gradle/
local.properties
.idea/
navigation-sample/secrets.properties
BOB_DATA/
50 changes: 32 additions & 18 deletions map-sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
134 changes: 0 additions & 134 deletions map-sample/app/build.gradle

This file was deleted.

121 changes: 121 additions & 0 deletions map-sample/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
}
}
}
1 change: 0 additions & 1 deletion map-sample/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapdemo"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="1"
android:versionName="1.0">
Expand Down
54 changes: 0 additions & 54 deletions map-sample/build.gradle

This file was deleted.

13 changes: 12 additions & 1 deletion navigation-sample/settings.gradle → map-sample/build.gradle.kts
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
include ':app'

// 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)
}
Loading
Loading