diff --git a/.gitignore b/.gitignore
index 73145024..108a5ca2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ build/
*.iml
local.properties
.DS_Store
+secure.properties
diff --git a/ApiDemos/java/README.md b/ApiDemos/java/README.md
index 859188aa..0d1a310c 100644
--- a/ApiDemos/java/README.md
+++ b/ApiDemos/java/README.md
@@ -38,8 +38,8 @@ Alternatively use the `gradlew build` command to build the project directly.
This demo app requires that you add your own Google Maps API key:
1. [Get a Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)
-1. Create a file in the `ApiDemos/java` directory called `secure.properties` (this file should *NOT* be under version control to protect your API key)
-1. Add a single line to `ApiDemos/java/secure.properties` that looks like `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
+1. Create a file in the root directory called `secure.properties` (this file should *NOT* be under version control to protect your API key)
+1. Add a single line to `secure.properties` that looks like `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
1. Build and run
Support
diff --git a/ApiDemos/java/app/build.gradle b/ApiDemos/java/app/build.gradle
index fea3eeaa..d5ad7752 100644
--- a/ApiDemos/java/app/build.gradle
+++ b/ApiDemos/java/app/build.gradle
@@ -15,15 +15,15 @@ android {
versionName "1.0"
multiDexEnabled true
- // Read the API key from ApiDemos/java/secure.properties into R.string.maps_api_key
+ // Read the API key from ./secure.properties into R.string.maps_api_key
def secureProps = new Properties()
- if (file("../secure.properties").exists()) {
- file("../secure.properties")?.withInputStream { secureProps.load(it) }
+ if (file("../../../secure.properties").exists()) {
+ file("../../../secure.properties")?.withInputStream { secureProps.load(it) }
}
resValue "string", "maps_api_key", (secureProps.getProperty("MAPS_API_KEY") ?: "")
// To add your Maps API key to this project:
- // 1. Create a file ApiDemos/java/secure.properties
+ // 1. Create a file ./secure.properties
// 2. Add this line, where YOUR_API_KEY is your API key:
// MAPS_API_KEY=YOUR_API_KEY
}
diff --git a/ApiDemos/java/gradle.properties b/ApiDemos/java/gradle.properties
index 915f0e66..acf164f6 100644
--- a/ApiDemos/java/gradle.properties
+++ b/ApiDemos/java/gradle.properties
@@ -17,4 +17,4 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.enableJetifier=true
-android.useAndroidX=true
\ No newline at end of file
+android.useAndroidX=true
diff --git a/ApiDemos/kotlin/README.md b/ApiDemos/kotlin/README.md
index 67c40afa..871c867c 100644
--- a/ApiDemos/kotlin/README.md
+++ b/ApiDemos/kotlin/README.md
@@ -34,8 +34,8 @@ Alternatively use the `gradlew build` command to build the project directly.
This demo app requires that you add your own Google Maps API key:
1. [Get a Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)
-1. Create a file in the `ApiDemos/kotlin/app` directory called `secure.properties` (this file should *NOT* be under version control to protect your API key)
-1. Add a single line to `ApiDemos/kotlin/app/secure.properties` that looks like `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
+1. Create a file in the root directory called `secure.properties` (this file should *NOT* be under version control to protect your API key)
+1. Add a single line to `secure.properties` that looks like `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
1. Build and run
Support
diff --git a/ApiDemos/kotlin/app/build.gradle b/ApiDemos/kotlin/app/build.gradle
index a0c73a40..3180ed15 100644
--- a/ApiDemos/kotlin/app/build.gradle
+++ b/ApiDemos/kotlin/app/build.gradle
@@ -15,15 +15,15 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
- // Read the API key from ApiDemos/kotlin/secure.properties into R.string.maps_api_key
+ // Read the API key from ./secure.properties into R.string.maps_api_key
def secureProps = new Properties()
- if (file("../secure.properties").exists()) {
- file("../secure.properties")?.withInputStream { secureProps.load(it) }
+ if (file("../../../secure.properties").exists()) {
+ file("../../../secure.properties")?.withInputStream { secureProps.load(it) }
}
resValue "string", "maps_api_key", (secureProps.getProperty("MAPS_API_KEY") ?: "")
// To add your Maps API key to this project:
- // 1. Create a file ApiDemos/kotlin/secure.properties
+ // 1. Create a file ./secure.properties
// 2. Add this line, where YOUR_API_KEY is your API key:
// MAPS_API_KEY=YOUR_API_KEY
}
diff --git a/ApiDemos/kotlin/app/src/main/res/values/google_maps_api.xml b/ApiDemos/kotlin/app/src/main/res/values/google_maps_api.xml
deleted file mode 100644
index c046c6e0..00000000
--- a/ApiDemos/kotlin/app/src/main/res/values/google_maps_api.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- YOUR_API_KEY
-
-
diff --git a/README.md b/README.md
index 63beeb55..cd0bc975 100644
--- a/README.md
+++ b/README.md
@@ -14,8 +14,7 @@ This repo contains the following samples:
Displays a map on a Wear OS device. This sample demonstrates the basic
setup required for a gradle-based Android Studio project.
1. [Tutorials](https://github.com/googlemaps/android-samples/tree/master/tutorials): Samples
-associated with tutorials in the developer's guide. See each sample for a link to the associated
-guide.
+associated with tutorials in the developer's guide. See each sample for a link to the associated guide.
Pre-requisites
@@ -37,12 +36,14 @@ In Android Studio, use the "Import non-Android Studio project" or
repository.
If prompted for a gradle configuration accept the default settings.
-Alternatively use the "gradlew build" command to build the project directly.
+Alternatively use the `gradlew build` command to build the project directly.
-Search for `YOUR_API_KEY` in the project and replace it with your API key.
-Some samples store this in the gradle.properties file and others store it in the google_maps_api.xml file.
-See the [Get Started with Google Maps Platform](https://developers.google.com/maps/gmp-get-started)
-guide to get an API key.
+The demo apps require that you add your own Google Maps API key:
+
+1. [Get a Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)
+1. Create a file in the root directory called `secure.properties` (this file should *NOT* be under version control to protect your API key)
+1. Add a single line to `secure.properties` that looks like `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
+1. Build and run
Support
-------
diff --git a/secure.properties.template b/secure.properties.template
new file mode 100644
index 00000000..ad5874bf
--- /dev/null
+++ b/secure.properties.template
@@ -0,0 +1,3 @@
+# This is a template for the `secure.properties` file
+# To use this, replace "YOUR_API_KEY" with your GMP API key and rename this file to `secure.properties`
+MAPS_API_KEY="YOUR_API_KEY"
diff --git a/tutorials/java/CurrentPlaceDetailsOnMap/README.md b/tutorials/java/CurrentPlaceDetailsOnMap/README.md
index 1c98a921..be9f59a0 100644
--- a/tutorials/java/CurrentPlaceDetailsOnMap/README.md
+++ b/tutorials/java/CurrentPlaceDetailsOnMap/README.md
@@ -22,11 +22,15 @@ This sample uses the Gradle build system.
"Import Project" option.
1. Select the `CurrentPlaceDetailsOnMap` directory that you downloaded with this repository.
1. If prompted for a gradle configuration, accept the default settings.
- Alternatively use the "gradlew build" command to build the project directly.
-1. Add your API key to your app's `gradle.properties` file.
- (For information on getting an API key, see the
- [documentation](https://developers.google.com/maps/documentation/android-api/signup).)
+ Alternatively use the `gradlew build` command to build the project directly.
+This demo app requires that you add your own Google Maps API key:
+
+ 1. [Get a Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)
+ 1. Create a file in the root directory called `secure.properties` (this file should *NOT* be under version control to protect your API key)
+ 1. Add a single line to `secure.properties` that looks like `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
+ 1. Build and run
+
Support
-------
diff --git a/tutorials/java/CurrentPlaceDetailsOnMap/app/build.gradle b/tutorials/java/CurrentPlaceDetailsOnMap/app/build.gradle
index 810de56f..dad23acf 100644
--- a/tutorials/java/CurrentPlaceDetailsOnMap/app/build.gradle
+++ b/tutorials/java/CurrentPlaceDetailsOnMap/app/build.gradle
@@ -10,7 +10,19 @@ android {
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- resValue "string", "google_maps_key", (project.findProperty("GOOGLE_MAPS_API_KEY") ?: "")
+
+ // Read the API key from ./secure.properties into R.string.maps_api_key
+ def secureProps = new Properties()
+ if (file("../../../../secure.properties").exists()) {
+ file("../../../../secure.properties")?.withInputStream { secureProps.load(it) }
+ }
+ resValue "string", "maps_api_key", (secureProps.getProperty("MAPS_API_KEY") ?: "")
+
+ // To add your Maps API key to this project:
+ // 1. Create a file ./secure.properties
+ // 2. Add this line, where YOUR_API_KEY is your API key:
+ // MAPS_API_KEY=YOUR_API_KEY
+
}
buildTypes {
debug {
diff --git a/tutorials/java/CurrentPlaceDetailsOnMap/app/src/main/AndroidManifest.xml b/tutorials/java/CurrentPlaceDetailsOnMap/app/src/main/AndroidManifest.xml
index 4e780eb1..9f1a7b7e 100644
--- a/tutorials/java/CurrentPlaceDetailsOnMap/app/src/main/AndroidManifest.xml
+++ b/tutorials/java/CurrentPlaceDetailsOnMap/app/src/main/AndroidManifest.xml
@@ -19,7 +19,7 @@
-->
+ android:value="@string/maps_api_key" />
+ android:value="@string/maps_api_key" />
@@ -30,4 +30,4 @@
-
\ No newline at end of file
+
diff --git a/tutorials/kotlin/CurrentPlaceDetailsOnMap/README.md b/tutorials/kotlin/CurrentPlaceDetailsOnMap/README.md
index 1c98a921..a9362f23 100644
--- a/tutorials/kotlin/CurrentPlaceDetailsOnMap/README.md
+++ b/tutorials/kotlin/CurrentPlaceDetailsOnMap/README.md
@@ -22,10 +22,15 @@ This sample uses the Gradle build system.
"Import Project" option.
1. Select the `CurrentPlaceDetailsOnMap` directory that you downloaded with this repository.
1. If prompted for a gradle configuration, accept the default settings.
- Alternatively use the "gradlew build" command to build the project directly.
-1. Add your API key to your app's `gradle.properties` file.
- (For information on getting an API key, see the
- [documentation](https://developers.google.com/maps/documentation/android-api/signup).)
+ Alternatively use the `gradlew build` command to build the project directly.
+
+This demo app requires that you add your own Google Maps API key:
+
+ 1. [Get a Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)
+ 1. Create a file in the root directory called `secure.properties` (this file should *NOT* be under version control to protect your API key)
+ 1. Add a single line to `secure.properties` that looks like `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
+ 1. Build and run
+
Support
-------
diff --git a/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/build.gradle b/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/build.gradle
index 7e1436c9..e26e8e05 100644
--- a/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/build.gradle
+++ b/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/build.gradle
@@ -12,7 +12,19 @@ android {
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- resValue "string", "google_maps_key", (project.findProperty("GOOGLE_MAPS_API_KEY") ?: "")
+
+ // Read the API key from ./secure.properties into R.string.maps_api_key
+ def secureProps = new Properties()
+ if (file("../../../../secure.properties").exists()) {
+ file("../../../../secure.properties")?.withInputStream { secureProps.load(it) }
+ }
+ resValue "string", "maps_api_key", (secureProps.getProperty("MAPS_API_KEY") ?: "")
+
+ // To add your Maps API key to this project:
+ // 1. Create a file ./secure.properties
+ // 2. Add this line, where YOUR_API_KEY is your API key:
+ // MAPS_API_KEY=YOUR_API_KEY
+
}
buildTypes {
debug {
diff --git a/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/AndroidManifest.xml b/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/AndroidManifest.xml
index 4e780eb1..0db22bb8 100644
--- a/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/AndroidManifest.xml
+++ b/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/AndroidManifest.xml
@@ -19,7 +19,7 @@
-->
+ android:value="@string/maps_api_key" />
-
\ No newline at end of file
+
diff --git a/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/java/com/example/currentplacedetailsonmap/MapsActivityCurrentPlace.kt b/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/java/com/example/currentplacedetailsonmap/MapsActivityCurrentPlace.kt
index 7cef4b83..59e2a0bf 100644
--- a/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/java/com/example/currentplacedetailsonmap/MapsActivityCurrentPlace.kt
+++ b/tutorials/kotlin/CurrentPlaceDetailsOnMap/app/src/main/java/com/example/currentplacedetailsonmap/MapsActivityCurrentPlace.kt
@@ -89,7 +89,7 @@ class MapsActivityCurrentPlace : AppCompatActivity(), OnMapReadyCallback {
// [START_EXCLUDE silent]
// Construct a PlacesClient
- Places.initialize(applicationContext, getString(R.string.google_maps_key))
+ Places.initialize(applicationContext, getString(R.string.maps_api_key))
placesClient = Places.createClient(this)
// Construct a FusedLocationProviderClient.
@@ -407,4 +407,4 @@ class MapsActivityCurrentPlace : AppCompatActivity(), OnMapReadyCallback {
// Used for selecting the current place.
private const val M_MAX_ENTRIES = 5
}
-}
\ No newline at end of file
+}
diff --git a/tutorials/kotlin/MapWithMarker/README.md b/tutorials/kotlin/MapWithMarker/README.md
index 75ef5d1e..8718f456 100644
--- a/tutorials/kotlin/MapWithMarker/README.md
+++ b/tutorials/kotlin/MapWithMarker/README.md
@@ -22,15 +22,14 @@ This sample uses the Gradle build system.
`tutorials/kotlin/MapWithMarker` directory that you downloaded
1. If prompted for a gradle configuration, accept the default settings.
Alternatively use the `gradlew build` command to build the project directly.
-
+
This demo app requires that you add your own Google Maps API key:
-1. [Get a Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)
-1. Create a file in the `tutorials/kotlin/MapWithMarker` directory called `secure.properties`
- (this file should *NOT* be under version control to protect your API key)
-1. Add a single line to `tutorials/kotlin/MapWithMarker/secure.properties` that looks like
- `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
-1. Build and run
+ 1. [Get a Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)
+ 1. Create a file in the root directory called `secure.properties` (this file should *NOT* be under version control to protect your API key)
+ 1. Add a single line to `secure.properties` that looks like `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
+ 1. Build and run
+
Support
-------
diff --git a/tutorials/kotlin/MapWithMarker/app/build.gradle b/tutorials/kotlin/MapWithMarker/app/build.gradle
index a11b314f..f8f79d23 100644
--- a/tutorials/kotlin/MapWithMarker/app/build.gradle
+++ b/tutorials/kotlin/MapWithMarker/app/build.gradle
@@ -13,15 +13,15 @@ android {
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- // Read the API key from tutorials/kotlin/MapWithMarker/app/secure.properties into R.string.maps_api_key
+ // Read the API key from ./secure.properties into R.string.maps_api_key
def secureProps = new Properties()
- if (file("secure.properties").exists()) {
- file("secure.properties")?.withInputStream { secureProps.load(it) }
+ if (file("../../../../secure.properties").exists()) {
+ file("../../../../secure.properties")?.withInputStream { secureProps.load(it) }
}
resValue "string", "maps_api_key", (secureProps.getProperty("MAPS_API_KEY") ?: "")
// To add your Maps API key to this project:
- // 1. Create a file tutorials/kotlin/MapWithMarker/app/secure.properties
+ // 1. Create a file ./secure.properties
// 2. Add this line, where YOUR_API_KEY is your API key:
// MAPS_API_KEY=YOUR_API_KEY
}
diff --git a/tutorials/kotlin/Polygons/README.md b/tutorials/kotlin/Polygons/README.md
index e47c5c36..ccafe9a5 100644
--- a/tutorials/kotlin/Polygons/README.md
+++ b/tutorials/kotlin/Polygons/README.md
@@ -23,15 +23,13 @@ This sample uses the Gradle build system.
1. Select the `Polygons` directory that you downloaded with this repository.
1. If prompted for a gradle configuration, accept the default settings.
Alternatively use the `gradlew build` command to build the project directly.
-
+
This demo app requires that you add your own Google Maps API key:
-1. [Get a Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)
-1. Create a file in the `tutorials/kotlin/Polygons/app` directory called `secure.properties`
- (this file should *NOT* be under version control to protect your API key)
-1. Add a single line to `tutorials/kotlin/Polygons/secure.properties` that looks like
- `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
-1. Build and run
+ 1. [Get a Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)
+ 1. Create a file in the root directory called `secure.properties` (this file should *NOT* be under version control to protect your API key)
+ 1. Add a single line to `secure.properties` that looks like `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
+ 1. Build and run
Support
-------
diff --git a/tutorials/kotlin/Polygons/app/build.gradle b/tutorials/kotlin/Polygons/app/build.gradle
index 932a919e..f6f5e005 100644
--- a/tutorials/kotlin/Polygons/app/build.gradle
+++ b/tutorials/kotlin/Polygons/app/build.gradle
@@ -13,15 +13,15 @@ android {
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- // Read the API key from tutorials/java/Polygons/app/secure.properties into R.string.maps_api_key
+ // Read the API key from ./secure.properties into R.string.maps_api_key
def secureProps = new Properties()
- if (file("secure.properties").exists()) {
- file("secure.properties")?.withInputStream { secureProps.load(it) }
+ if (file("../../../../secure.properties").exists()) {
+ file("../../../../secure.properties")?.withInputStream { secureProps.load(it) }
}
resValue "string", "maps_api_key", (secureProps.getProperty("MAPS_API_KEY") ?: "")
// To add your Maps API key to this project:
- // 1. Create a file tutorials/java/Polygons/app/secure.properties
+ // 1. Create a file ./secure.properties
// 2. Add this line, where YOUR_API_KEY is your API key:
// MAPS_API_KEY=YOUR_API_KEY
}