我是android的新手,面对map的问题。在我的应用程序中,我可以看到包含地图的框但是地图除了白色网格外什么也没有显示,我看到一些以前的stackoverflow回答了同样的问题,但仍然不能解决问题。请帮助我。谢谢。
我的清单文件包含
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET">
</uses-permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name=".Main"
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.AIzaSyDhp2d1pq1R7qg0p4BjqdTCwaRuuXckTJU"
android:value="AIzaSyDhp2d1pq1R7qg0p4BjqdTCwaRuuXckTJU"/>
</application>
</manifest>
我的布局活动文件包含:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<com.google.android.maps.MapView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:apiKey="AIzaSyDhp2d1pq1R7qg0p4BjqdTCwaRuuXckTJU"
android:id="@+id/mapdata"
/>
</LinearLayout>
我从unix命令获得了这个键
sau@sau-HP-Pavilion-dv6-Notebook-PC:/usr/local/java/jdk1.8.0_20/bin$ ./keytool
-list -alias androiddebugkey -keystore /home/sau/.android/debug.keystore
-storepass android -keypass android androiddebugkey, 11 Oct, 2014, PrivateKeyEntry,
Certificate fingerprint (SHA1): 32:6D:54:16:96:66:82:39:EC:4C:5B:3A:16:79:
B3:96:EF:77:9D:C2
我使用这个sha1来获取密钥AIzaSyDhp2d1pq1R7qg0p4BjqdTCwaRuuXckTJU,
Key for Android apps (with certificates)
API key:
AIzaSyDhp2d1pq1R7qg0p4BjqdTCwaRuuXckTJU
Android apps:
32:6D:54:16:96:66:82:39:EC:4C:5B:3A:16:79:B3:96:EF:77:9D:C2;com.example.maps
Activated on: Oct 30, 2014 12:05 AM
Activated by: saurabh.saluja2013@gmail.com – you
我做错了什么?
答案 0 :(得分:0)
你的宣言应该是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.errorpoint.findlocation"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.errorpoint.findlocation.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.errorpoint.findlocation.permission.MAPS_RECEIVE" />
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
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.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Key goes here" />
</application>
</manifest>
xml文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
在Github中查看我的完整示例; Link