我对Google地图有疑问:不会显示地图,只显示如下白色地图图块:http://oi47.tinypic.com/2uh0sk0.jpg
我试图生成一个新的API密钥,但它仍然无效,我无法理解为什么......
这里是logcat:
04-02 11:04:07.459: W/dalvikvm(32502): VFY: unable to resolve virtual method 3693: Lcom/fullwipe/bolognacityguide/Mapexample;.getFragmentManager ()Landroid/app/FragmentManager;
04-02 11:04:07.499: W/dalvikvm(32502): VFY: unable to resolve instance field 23
04-02 11:04:07.859: W/dalvikvm(32502): Unable to resolve superclass of Lmaps/p/s; (425)
04-02 11:04:07.859: W/dalvikvm(32502): Link of class 'Lmaps/p/s;' failed
04-02 11:04:07.859: W/dalvikvm(32502): Unable to resolve superclass of Lmaps/y/bo; (3818)
04-02 11:04:07.859: W/dalvikvm(32502): Link of class 'Lmaps/y/bo;' failed
04-02 11:04:07.859: W/dalvikvm(32502): Unable to resolve superclass of Lmaps/i/k; (4206)
04-02 11:04:07.859: W/dalvikvm(32502): Link of class 'Lmaps/i/k;' failed
04-02 11:04:07.859: E/dalvikvm(32502): Could not find class 'maps.i.k', referenced from method maps.z.ag.a
04-02 11:04:07.859: W/dalvikvm(32502): VFY: unable to resolve new-instance 3538 (Lmaps/i/k;) in Lmaps/z/ag;
04-02 11:04:09.449: E/Adreno200-ES20(32502): **** 32547: glUseProgram(0)
04-02 11:04:10.109: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 0
04-02 11:04:10.109: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:10.119: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 1
04-02 11:04:10.119: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:11.869: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 0
04-02 11:04:11.949: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:11.979: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 1
04-02 11:04:11.999: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:12.069: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 0
04-02 11:04:12.089: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:12.199: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 1
04-02 11:04:12.199: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:12.239: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 0
04-02 11:04:12.249: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:12.279: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 1
04-02 11:04:12.299: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="9"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera"
android:required="false"/>
<uses-feature android:name="android.hardware.camera.any"
android:required="false" />
<permission android:name="com.kurtis.myapp.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.kurtis.myapp.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<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:icon="@drawable/icona"
android:label="@string/app_name" >
<activity
android:name="com.kurtis.myapp.Home"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.kurtis.myapp.Mapexample"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaXXXXXXXXXXXXXXXXXXXXXXXXXq9M" />
</application>
</manifest>
的活动:
package com.kurtis.myapp;
import com.example.android.R;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.SupportMapFragment;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
@SuppressLint("NewApi")
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class Mapexample extends FragmentActivity {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapexample);
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
}
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
// The Map is verified. It is now safe to manipulate the map.
}
}
}
}
布局:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
你有任何想法解决这个问题吗?
答案 0 :(得分:2)
你在android显示文件中的包名有问题:
检查一下:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android"
android:versionCode="1"
android:versionName="1.0" >
和
<permission android:name="com.kurtis.myapp.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.kurtis.myapp.permission.MAPS_RECEIVE"/>
纠正它。
您为MAPS_RECEIVE
添加了不同的权限,然后如何重新映射地图?将其更改为
<permission android:name="com.example.android.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.example.android.permission.MAPS_RECEIVE"/>
答案 1 :(得分:0)
生成API密钥时,请确保您也在DEBUG模式下执行此操作 我想,这就是问题的根本原因。
你需要两个独立的钥匙;一个用于DEV(未经签名的应用程序用于模拟器等)
和一个LIVE(在签署你的应用程序时使用)。
答案 2 :(得分:0)
您在清单中的包名称应为:com.kurtis.myapp
而不是com.example.android
尝试在布局中使用class="com.google.android.gms.maps.MapFragment"
在您的主要活动中使用Activity而不是FragmentActivity并替换
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
用这个:
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
希望这有用
答案 3 :(得分:0)
在Google API控制台中,请确保您已启用“Google Maps Android API v2”服务,而不仅仅是“Google Maps API v2”服务。