-1

I'm using Google Maps API v2 for android and Google Places API, both have different api-keys to be added to manifest, but when i add both the keys, i got multiple-key error.

Is it possible to add two different keys for two different APIs, if not, then what is the possible work around?

    <!-- Goolge Maps API Key -->
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyD****************U6QybngOI" />

   <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="AIzaSyA******************KDaKCEJU" />
Qasim
  • 5,181
  • 4
  • 30
  • 51

4 Answers4

3

You will want to use gradle with Placeholders.

<meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="${mapsKey}" />

And in your gradle add

android {
   buildTypes {
    debug {
      manifestPlaceholders = [ mapsKey:"AIzaSyD****************U6QybngOI"]
    }
   }
}
David Medenjak
  • 33,993
  • 14
  • 106
  • 134
1

I solved the issue by using the same GEO API key for both Google Maps v2 and Google Places API, i-e the Geo api-key can be used for both places api and maps api as well.

<!-- Goolge Maps API Key -->
<meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="AIzaSyA******************KDaKCEJU" />    

<!-- Google Places API Key -->
<meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="AIzaSyA******************KDaKCEJU" />    
Qasim
  • 5,181
  • 4
  • 30
  • 51
0

To add release and debug keys change your gradle file. You first have to make the API keys in the Google Developer Console.

apply plugin: 'com.android.application'

android {
signingConfigs {

}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
    applicationId 'com.your.app'
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        manifestPlaceholders = [ mapsKey:"AIzaxxxxxxxxxxxxxxxxxxxvcgdXNA"]
    }
    debug {
        manifestPlaceholders = [ mapsKey:"AIzayyyyyyyyyyyyyyyyyyyyyyyC7NA"]
    }
}
productFlavors {
}
}

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.google.android.gms:play-services:8.4.0' }

ketan
  • 19,129
  • 42
  • 60
  • 98
Wil
  • 351
  • 3
  • 9
0

You shouldn't use multiple key for this purpose. You just have to Enable Both services for the same API key, from the developers console.I think this answer will guide you through The process.

Community
  • 1
  • 1
S.Ahsan
  • 389
  • 3
  • 15