gpt4 book ai didi

android - 谷歌地图不显示

转载 作者:行者123 更新时间:2023-11-29 00:32:31 27 4
gpt4 key购买 nike

我正在尝试使用谷歌地图创建一个应用程序。我使用了 google maps api v2,但 map 没有显示。我只看到带有缩放按钮的灰色屏幕。

有什么想法吗?我很确定错误不在 API key 中..

这是我的代码..

Android list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.examplemaps.rs"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<permission
android:name="com.examplemaps.rs.MAPS_RECEIVE"
android:protectionLevel = "signature"/>

<uses-permission android:name="com.examplemaps.rs.MAPS_RECEIVE" />
<uses-feature android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.examplemaps.rs.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<activity
android:name="com.examplemaps.rs.Home"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyB5aBact***myAPI key"/>


</application>

</manifest>

首页.java:

 package com.examplemaps.rs;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

public class Home extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_home, menu);
return true;
}

}

和activity_home.xml

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Home" >

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="wrap_content"
android:layout_height="match_parent" />

</RelativeLayout>

谢谢!

最佳答案

我发现了错误。在 Android list 中,我将 READ_GSERVICES 替换为:

 <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

现在,它工作正常!

关于android - 谷歌地图不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14565885/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com