Google Maps Setup
This section covers the setup process for Google Maps SDK integration with MapConductor.
Important: MapConductor provides a unified API layer on top of existing map SDKs. You must set up the Google Maps SDK independently before using MapConductor’s Google Maps integration.
Prerequisites
Section titled “Prerequisites”- Android development environment
- Google Cloud Console account
- Maps SDK for Android enabled in your Google Cloud project
Setup Steps
Section titled “Setup Steps”1. Google Cloud Console Configuration
Section titled “1. Google Cloud Console Configuration”- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Maps SDK for Android API
- Go to Credentials and create an API key
- Restrict the API key to your app’s package name and SHA-1 certificate fingerprint
2. Gradle Configuration
Section titled “2. Gradle Configuration”First, add the Secrets Gradle Plugin to your project’s root build.gradle.kts:
// Root build.gradle.ktsplugins { id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") version "2.0.1" apply false}Then, add the dependencies and apply the plugin in your app’s build.gradle.kts:
// App build.gradle.ktsplugins { // ... other plugins id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")}
dependencies { // Google Maps SDK (version managed via libs.versions.toml) implementation(libs.play.services.maps)
// MapConductor BOM for version management (v1.1.2) implementation(platform("com.mapconductor:mapconductor-bom:1.1.2"))
// MapConductor modules (versions managed by BOM) implementation("com.mapconductor:core") implementation("com.mapconductor:for-googlemaps")}The Secrets Gradle Plugin automatically reads your secrets.properties file and injects the values into your AndroidManifest.xml at build time.
3. Android Manifest Configuration
Section titled “3. Android Manifest Configuration”Add the Google Maps API key placeholder to your AndroidManifest.xml:
<application> <!-- Google Maps API Key --> <meta-data android:name="com.google.android.geo.API_KEY" android:value="${GOOGLE_MAPS_API_KEY}" />
<!-- Add location permissions --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /></application>4. API Key Configuration
Section titled “4. API Key Configuration”Add your actual API key to your secrets.properties file (create if it doesn’t exist):
GOOGLE_MAPS_API_KEY=your_actual_google_maps_api_key_hereImportant:
- Never commit your
secrets.propertiesfile to version control. Add it to.gitignore. - The Secrets Gradle Plugin automatically replaces
${GOOGLE_MAPS_API_KEY}in yourAndroidManifest.xmlwith the actual value from this file. - For CI/CD builds, you can set environment variables or use other secure methods to provide these values.
5. ProGuard / R8 Configuration (if applicable)
Section titled “5. ProGuard / R8 Configuration (if applicable)”If you’re using ProGuard/R8, add these rules to your proguard-rules.pro:
# Google Play Services-keep class com.google.android.gms.maps.** { *; }-keep interface com.google.android.gms.maps.** { *; }-dontwarn com.google.android.gms.**Verification
Section titled “Verification”To verify your Google Maps setup:
- Build and run your app
- Check that the map displays without errors
- Verify location permissions are working
- Test basic map interactions (zoom, pan)
@Composablefun TestGoogleMaps() { val mapState = rememberGoogleMapViewState()
GoogleMapView(state = mapState) { // If this displays correctly, your setup is working }}Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Map not displaying (gray screen)
- Verify API key is correct in
secrets.properties - Check that Maps SDK for Android is enabled in Google Cloud Console
- Ensure API key restrictions match your app’s package name and SHA-1
API key errors in logs
- Double-check the API key value
- Verify the key has not expired
- Check API key restrictions in Google Cloud Console
Build errors
- Ensure the Play Services Maps dependency matches your project configuration
- Verify
secrets.propertiesfile exists and is properly formatted - Check that
secrets.propertiesis not accidentally ignored for local builds
Next Steps
Section titled “Next Steps”Once Google Maps SDK is properly configured, you can use MapConductor’s GoogleMapView component as described in the Map View component documentation.