简体   繁体   中英

google maps api key not found (but i put)

The error is:

Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class fragment
Caused by: java.lang.RuntimeException: 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
                                                                             at com.google.maps.api.android.lib6.c.ad.a(Unknown Source)
                                                                             at com.google.maps.api.android.lib6.a.e.a(Unknown Source)
                                                                             at com.google.android.gms.maps.internal.CreatorImpl.b(Unknown Source)
                                                                             at com.google.android.gms.maps.internal.CreatorImpl.b(Unknown Source)
                                                                             at com.google.android.gms.maps.internal.h.onTransact(SourceFile:62)

Show_description.xml:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="99dp"
        android:id="@+id/scroll_desc">

        <TextView
              android:id="@+id/desc"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"/>

    </ScrollView>

    <fragment//line 18 here
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/scroll_desc" />

</RelativeLayout>

A textview insinde scrollview and a map here.

manifest:

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

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

    <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">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity android:name=".ListEvents" />
        <activity android:name=".ShowEventMap" />
        <activity android:name=".AndroidDatabaseManager"
            android:theme="@style/Theme.AppCompat.Light"/>
    </application>

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

</manifest>

I was doing this project for weeks. Yesterday i decided to map so i changed dependency

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile project(':jsoup-1.8.3')
compile 'com.google.android.gms:play-services-maps:8.3.0'

}

Probably i wont need any location service or some others so i decided to use only maps so i added only maps as service.

https://console.developers.google.com/apis/credentials?project=showmeevets

here i created a new project with same name of my project in android studio and then create a new credential. Did not get the signature from my project. Can it be reason?

I just got the key from the link i just provided.

You are using com.google.android.gms:play-services-maps:8.3.0 so You need to replace com.google.android.geo.API_KEY with com.google.android.maps.v2.API_KEY

As per your error log:

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

Place Your meta-data tag inside of <application> </application> tag

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

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

    <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">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity android:name=".ListEvents" />
        <activity android:name=".ShowEventMap" />
        <activity android:name=".AndroidDatabaseManager"
            android:theme="@style/Theme.AppCompat.Light"/>

 <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="xxxxx" />
</application>
</manifest>

Add this meta-data

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM