mirror of
https://github.com/googlemaps/android-samples.git
synced 2025-12-08 18:02:20 +00:00
* feat: Using local.properties to provide API key instead of secure.properties. * Remove redundant declaration in main AndroidManifest.xml * Migrate ApiDemos - Kotlin to use local.properties. * Update README for tutorials. * Genericize. * Remove references to secure.properties. * s/master/main
52 lines
1.8 KiB
Groovy
52 lines
1.8 KiB
Groovy
apply plugin: 'com.android.application'
|
|
|
|
// 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())
|
|
}
|
|
def mapsApiKey = properties.getProperty("MAPS_API_KEY", "")
|
|
|
|
android {
|
|
compileSdkVersion 29
|
|
buildToolsVersion "28.0.3"
|
|
defaultConfig {
|
|
applicationId "com.example.mapwithmarker"
|
|
minSdkVersion 16
|
|
targetSdkVersion 29
|
|
versionCode 1
|
|
versionName "1.0"
|
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
|
|
|
// Read the API key from local.properties into R.string.maps_api_key
|
|
resValue "string", "maps_api_key", mapsApiKey
|
|
|
|
// 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
|
|
|
|
}
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled false
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
}
|
|
}
|
|
}
|
|
|
|
// [START maps_android_play_services_maps_dependency]
|
|
dependencies {
|
|
implementation 'com.google.android.gms:play-services-maps:17.0.0'
|
|
// [START_EXCLUDE]
|
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
|
testImplementation 'junit:junit:4.13.1'
|
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
|
// [END_EXCLUDE]
|
|
}
|
|
// [END maps_android_play_services_maps_dependency]
|