mirror of
https://github.com/googlemaps/android-samples.git
synced 2025-12-08 18:02:20 +00:00
docs: Update README on how to provide GMP API Key. (#248)
* docs: Update README on how to provide GMP API Key. * fix references. * Update reference. * Update string. * Update references.
This commit is contained in:
parent
e37665bebb
commit
7768691408
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ build/
|
||||
*.iml
|
||||
local.properties
|
||||
.DS_Store
|
||||
secure.properties
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
android.useAndroidX=true
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
<resources>
|
||||
<!--
|
||||
TODO: Before you run your application, you need a Google Maps API key.
|
||||
|
||||
See this page for more information:
|
||||
https://developers.google.com/maps/gmp-get-started
|
||||
|
||||
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
|
||||
string in this file.
|
||||
|
||||
Note: This resource is used for the debug build target. Update this file if you just want to run
|
||||
the demo app.
|
||||
-->
|
||||
<string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">
|
||||
YOUR_API_KEY
|
||||
</string>
|
||||
</resources>
|
||||
15
README.md
15
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
|
||||
-------
|
||||
|
||||
3
secure.properties.template
Normal file
3
secure.properties.template
Normal file
@ -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"
|
||||
@ -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
|
||||
-------
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
-->
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="@string/google_maps_key" />
|
||||
android:value="@string/maps_api_key" />
|
||||
|
||||
<activity
|
||||
android:name="com.example.currentplacedetailsonmap.MapsActivityCurrentPlace"
|
||||
|
||||
@ -115,7 +115,7 @@ public class MapsActivityCurrentPlace extends AppCompatActivity
|
||||
|
||||
// [START_EXCLUDE silent]
|
||||
// Construct a PlacesClient
|
||||
Places.initialize(getApplicationContext(), getString(R.string.google_maps_key));
|
||||
Places.initialize(getApplicationContext(), getString(R.string.maps_api_key));
|
||||
placesClient = Places.createClient(this);
|
||||
|
||||
// Construct a FusedLocationProviderClient.
|
||||
|
||||
@ -22,15 +22,13 @@ This sample uses the Gradle build system.
|
||||
`tutorials/java/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/java/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/java/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
|
||||
-------
|
||||
|
||||
@ -11,15 +11,15 @@ android {
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
// Read the API key from tutorials/java/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/java/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
|
||||
}
|
||||
|
||||
@ -26,12 +26,10 @@ This sample uses the Gradle build system.
|
||||
|
||||
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/java/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/java/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
|
||||
-------
|
||||
|
||||
@ -11,17 +11,18 @@ 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
|
||||
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
@ -38,4 +39,4 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.13'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,9 +23,13 @@ This sample uses the Gradle build system.
|
||||
1. Select the `StyledMap` 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).)
|
||||
|
||||
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
|
||||
-------
|
||||
|
||||
@ -10,7 +10,18 @@ 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 {
|
||||
release {
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
-->
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="@string/google_maps_key" />
|
||||
android:value="@string/maps_api_key" />
|
||||
|
||||
<activity android:name=".MapsActivityRaw"
|
||||
android:label="@string/title_activity_maps">
|
||||
@ -30,4 +30,4 @@
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
|
||||
@ -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
|
||||
-------
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
-->
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="@string/google_maps_key" />
|
||||
android:value="@string/maps_api_key" />
|
||||
|
||||
<activity
|
||||
android:name="com.example.currentplacedetailsonmap.MapsActivityCurrentPlace"
|
||||
@ -32,4 +32,4 @@
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
-------
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
-------
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user