Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

API key not found

I'm trying out React Native Maps but get this when I do react-native run-android:

API key not found.  Check that <meta-data android:name="com.google.android.geo.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml

My meta-data tag from AndroidManifest.xml:

<meta-data
android:name="com.google.android.geo.maptest"
android:value="A***Q"
/>

I have tried restarting the packager.

Solution: android:name="com.google.android.geo.API_KEY" is literal and shouldn't be changed.

like image 702
Ray Lee Avatar asked Aug 06 '17 18:08

Ray Lee


People also ask

Where is my API key?

Go to the Google Maps Platform > Credentials page. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key.

What is API key in Android?

The API key is a unique identifier that authenticates requests associated with your project for usage and billing purposes. You must have at least one API key associated with your project. To create an API key: Console Cloud SDK.

Why is my Google Maps API key not working?

There are a several reasons why your google maps may not be working, the most common issue being no Google Map API key set or set incorrectly. To use the Google Maps JavaScript API, you must register your app project on the Google Cloud Platform Console and get a Google API key which you can add to your app.


2 Answers

In your AndroidManifest.xml file add the following :-

<meta-data
      android:name="com.google.android.geo.API_KEY"
      android:value="Your Google maps API Key Here"/>

and then run react-native run-android again and you are good to go :)

edit

You can't change the literal "API_KEY" in android:name, Set the android:name as "com.google.android.geo.API_KEY"

like image 106
Akshay Rao Avatar answered Oct 10 '22 14:10

Akshay Rao


In AndroidManifest.xml, add the following element as a child of the application: AppName\android\app\src\main\AndroidManifest.xml:

  <application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:roundIcon="@mipmap/ic_launcher_round"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="Your API Key Will be inserted here"/>
  <activity......

Then rebuild the app and this will solve the problem. Snapshot of AndroidManifest.xml

like image 42
PrateekHIT Avatar answered Oct 10 '22 15:10

PrateekHIT