[英]google maps api key not found (but i put)
错误是:
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>
这里有一个textview insinde scrollview和一个地图。
表现:
<?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>
我做了这个项目好几个星期。 昨天我决定地图,所以我改变了依赖性
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'
}
可能我不需要任何定位服务或其他一些定位服务,所以我决定只使用地图,因此只添加了地图作为服务。
https://console.developers.google.com/apis/credentials?project=showmeevets
在这里,我在android studio中创建了一个与项目名称相同的新项目,然后创建了新凭据。 没有从我的项目中获得签名。 可能是原因吗?
我刚刚从提供的链接中获取了密钥。
您正在使用com.google.android.gms:play-services-maps:8.3.0
因此您需要将com.google.android.geo.API_KEY
替换为com.google.android.maps.v2.API_KEY
根据您的错误日志:
元数据android:name =“ com.google.android.geo.API_KEY” android:value =“您的API密钥” />位于AndroidManifest.xmlckquote的<application>元素中
将您的meta-data
标记放在<application> </application>
标记内
<?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>
添加此元数据
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="xxxxx" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.