1

I'm trying to use both google maps API and places API in my android app (includes a map and a place autocomplete activity), but the API key I got for google maps doesn't seem to be working for the place autocomplete activity, I tried getting another key for the Places API but I have no idea how to include it in my project, my manifest file currently looks like this:

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.ciceroneltd.cicero">

 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

 <application
     android:allowBackup="true"
     android:icon="@mipmap/ic_launcher"
     android:label="@string/app_name"
     android:supportsRtl="true"
     android:theme="@style/AppTheme">
     <activity
         android:name=".MainActivity"
         android:label=""
         android:theme="@style/AppTheme.NoActionBar">
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />

             <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
     </activity>


     <meta-data
         android:name="com.google.android.geo.API_KEY"
         android:value="@string/google_maps_key" />

    <meta-data
         android:name="com.google.android.geo.API_KEY"
         android:value="@string/places_api_key" />

 </application>

of course that doesn't work

Odai Mohammed
  • 279
  • 1
  • 5
  • 18

3 Answers3

1

You have to make sure that API Key you are using matches with key in the API manager/credentials section :https://console.developers.google.com/apis/credentials

First, You need to login to your https://console.developers.google.com account.

Also make sure that your package name and SHA-1 certficate fingerprint are correct.

Vikas
  • 4,263
  • 1
  • 34
  • 39
1

Here is the correct answer:

In order to use more than one API in a single app you need to follow these steps:

  1. Create a new project in Google's developer console here.

  2. Enable the API/s you need to use in your app from the console.

  3. Create a new API key and add that to your manifest file.

You only need one API key for both APIs.

Odai Mohammed
  • 279
  • 1
  • 5
  • 18
  • I see that it is not clear for many developers how many keys they need, which keys they need, credentials. It is like a maze. – RobertoFRey Feb 03 '19 at 18:23
0

Following both permissions for google map

<meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="AIzaSyCYAAicaxLbddmixUhFQk70dKZnuDq4jc0" />

<meta-data
  android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version" />

Then this permision for place api

<meta-data
     android:name="com.google.android.geo.API_KEY"
     android:value="@string/places_api_key" />
Masum
  • 4,879
  • 2
  • 23
  • 28