谷歌地图显示灰色方块 [英] Google Map Displaying Grey Squares
问题描述
我做了一个非常简单的应用程序,只是显示一个谷歌地图。然而,它只是似乎显示灰色方块。
我troubleshooted都做几乎所有我可以。我5+遍检查了我的code,我比起来,甚至到其他教程。我重新做了我的API密钥3倍 - 他们没有工作
我正在使用的手机连接到无线网络。即使是仿真器将无法正常工作。我已经建立了清单中的库和权限。我想我已经做到了这一切,但它仍然无法正常工作...任何建议?
下面是我的code:
MapsActivity.java:
包net.learn2develop.GoogleMaps;
进口com.google.android.maps.MapActivity;
进口com.google.android.maps.MapView;
进口android.os.Bundle;
公共类MapsActivity扩展MapActivity
{
/ **第一次创建活动时调用。 * /
@覆盖
公共无效的onCreate(包savedInstanceState)
{
super.onCreate(savedInstanceState);
的setContentView(R.layout.main);
}
@覆盖
保护的布尔isRouteDisplayed(){
返回false;
}
}
main.xml中:
< XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT>
< com.google.android.maps.MapView
机器人:ID =@ + ID /图形页面
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:启用=真
机器人:可点击=真
机器人:apiKey =0duU2_tgS67qkUZIpmLVIo0IDvJDh4Ew1Mzh9Pg
/>
< / RelativeLayout的>
GoogleMapsManifest:
< XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=net.learn2develop.GoogleMaps
安卓版code =1
机器人:VERSIONNAME =1.0.0>
<使用-SDK安卓的minSdkVersion =7/>
<应用机器人:图标=@可绘制/图标机器人:标签=@字符串/ APP_NAME>
<使用库机器人:名称=com.google.android.maps/>
<活动机器人:名称=。MapsActivity
机器人:标签=@字符串/ APP_NAME>
<意向滤光器>
<作用机器人:名称=android.intent.action.MAIN/>
<类机器人:名称=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
< /用途>
<使用-权限的Android:名称=android.permission.INTERNET对/>
< /舱单>
但问题是,迈克使用与发布的密钥库,而不是调试密钥库的日食编译APK时使用生成的API密钥。
I've made a very simple app that just displays a Google map. However, it only seems to be displaying gray squares.
I've troubleshooted and have done virtually everything I could. I checked my code 5+ times over, I've compared it even to other tutorials. I've re-made my API key 3 times - none of them work.
The phone I'm using is connected to wireless. Even the emulator won't work. I have the library and permission established in the manifest. I think I've done just about everything, but it still doesn't work... any suggestions?
Here's my code:
MapsActivity.java:
package net.learn2develop.GoogleMaps;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class MapsActivity extends MapActivity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
main.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">
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0duU2_tgS67qkUZIpmLVIo0IDvJDh4Ew1Mzh9Pg"
/>
</RelativeLayout>
GoogleMapsManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.learn2develop.GoogleMaps"
android:versionCode="1"
android:versionName="1.0.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".MapsActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
The problem was that Mike was using an API key generated with the release keystore instead of the debug keystore that eclipse uses when compiling the apk.
这篇关于谷歌地图显示灰色方块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!