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/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/navigation-sample/settings.gradle b/map-sample/build.gradle.kts old mode 100755 new mode 100644 similarity index 62% rename from navigation-sample/settings.gradle rename to map-sample/build.gradle.kts index 46dcb06..6b5b818 --- a/navigation-sample/settings.gradle +++ b/map-sample/build.gradle.kts @@ -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) +} diff --git a/map-sample/gradle/libs.versions.toml b/map-sample/gradle/libs.versions.toml new file mode 100644 index 0000000..0deb0a2 --- /dev/null +++ b/map-sample/gradle/libs.versions.toml @@ -0,0 +1,38 @@ +[versions] +agp = "8.13.2" +annotation = "1.9.1" +appcompat = "1.7.1" +autoValue = "1.11.1" +constraintlayout = "2.2.1" +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" +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" } +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-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" } +leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary" } + +[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") 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..3ada349 100755 --- a/navigation-sample/README.md +++ b/navigation-sample/README.md @@ -1,30 +1,46 @@ # 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** +* **Places API (New)** (Required for the location search features) -- 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, 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 + 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..6cb3ace --- /dev/null +++ b/navigation-sample/app/build.gradle.kts @@ -0,0 +1,130 @@ +/* + * 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) + // 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") + } + + 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/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 @@ ("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..de8ae9d --- /dev/null +++ b/navigation-sample/gradle/libs.versions.toml @@ -0,0 +1,38 @@ +[versions] +agp = "8.13.2" +androidxLifecycle = "2.10.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" +material = "1.13.0" +mapsUtils = "3.9.0" +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-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" } +leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version.ref = "leakcanary" } + +[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.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")