错误是:
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滚动视图和一个地图在这里。
清单:
<?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中创建了一个与我的项目同名的新项目,然后创建了一个新凭据。没有从我的项目中得到签名。这会是理由吗?
我刚从我刚刚提供的链接中拿到了钥匙。
发布于 2015-12-30 13:17:47
您使用的是com.google.android.gms:play-services-maps:8.3.0
,因此需要用com.google.android.maps.v2.API_KEY
替换com.google.android.geo.API_KEY
根据您的错误日志:
元数据android:name="com.google.android.geo.API_KEY“android:value=”您的应用编程接口密钥“/>在AndroidManifest.xmlckquote
的元素中
发布于 2015-12-30 13:19:26
将您的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" />
https://stackoverflow.com/questions/34530239
复制相似问题