chore: Update snippet for consistent throughout docs. (#469)

This commit is contained in:
Chris Arriola 2021-02-26 10:02:38 -08:00 committed by GitHub
parent 7c4167c231
commit eee48d767d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 24 deletions

View File

@ -1,33 +1,23 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
plugins {
id 'com.android.application'
id 'kotlin-android'
// [START maps_android_secrets_gradle_plugin]
id 'com.google.secrets_gradle_plugin' version '0.5'
// [END maps_android_secrets_gradle_plugin]
}
// [START maps_android_api_key_security_manifest_placeholder]
android {
// [START_EXCLUDE silent]
compileSdkVersion 30
buildToolsVersion "29.0.3"
// [END_EXCLUDE]
defaultConfig {
// [START_EXCLUDE]
applicationId "com.google.maps.example"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// [END_EXCLUDE]
// Set the properties within `local.properties` into a `Properties` class so that values
// within `local.properties` (e.g. Maps API key) are accessible in this file.
Properties properties = new Properties()
if (rootProject.file("local.properties").exists()) {
properties.load(rootProject.file("local.properties").newDataInputStream())
}
// Inject the Maps API key into the manifest
manifestPlaceholders = [ mapsApiKey : properties.getProperty("MAPS_API_KEY", "") ]
}
// [START_EXCLUDE silent]
buildTypes {
release {
minifyEnabled false
@ -53,9 +43,7 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// [END_EXCLUDE]
}
// [END maps_android_api_key_security_manifest_placeholder]
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
@ -72,4 +60,8 @@ dependencies {
v3Implementation 'com.google.android.libraries.maps:maps:3.1.0-beta'
testImplementation 'junit:junit:4.13.2'
}
secrets {
defaultPropertiesFileName = 'local.defaults.properties'
}

View File

@ -28,7 +28,7 @@
<!-- [START maps_android_api_key_security_manifest_metadata] -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${mapsApiKey}" />
android:value="${MAPS_API_KEY}" />
<!-- [END maps_android_api_key_security_manifest_metadata] -->
</application>

View File

@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath "com.android.tools.build:gradle:4.1.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong

View File

@ -1,6 +1,6 @@
#Tue Aug 25 10:27:15 PDT 2020
#Fri Feb 26 09:19:32 PST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

View File

@ -0,0 +1 @@
MAPS_API_KEY=YOUR_API_KEY