API key not found

Ray*_*Lee 4 api-key react-native

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
Run Code Online (Sandbox Code Playgroud)

My meta-data tag from AndroidManifest.xml:

<meta-data
android:name="com.google.android.geo.maptest"
android:value="A***Q"
/>
Run Code Online (Sandbox Code Playgroud)

I have tried restarting the packager.

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

Aks*_*Rao 7

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"/>
Run Code Online (Sandbox Code Playgroud)

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"

  • 是的,这是一个字面值,所以您不能替换它,我希望它现在可以正常工作:) (2认同)