谷歌地图Api安卓密钥

时间:2010-05-16 12:39:37

标签: android android-emulator google-maps

我在测试包含google maps API的Android应用程序时遇到了一些问题。 ooficial API示例工作正常,但如果我将代码复制到我自己的项目中,它会一直说:“应用程序已意外停止”。我多次在密钥库中查找密钥并将其注册到谷歌。甚至尝试重新安装SDK。有人知道问题是什么吗?

提前致谢

05-16 14:31:11.142: ERROR/ActivityThread(662): Failed to find provider info for com.google.settings
05-16 14:31:11.150: ERROR/ActivityThread(662): Failed to find provider info for com.google.settings
05-16 14:31:12.598: ERROR/MediaPlayerService(542): Couldn't open fd for content://settings/system/notification_sound
05-16 14:31:12.624: ERROR/MediaPlayer(562): Unable to to create media player
05-16 14:31:05.098: ERROR/ActivityThread(608): Failed to find provider info for android.server.checkin
05-16 14:31:06.538: ERROR/ActivityThread(608): Failed to find provider info for android.server.checkin
05-16 14:31:06.645: ERROR/ActivityThread(608): Failed to find provider info for android.server.checkin
05-16 14:31:12.803: ERROR/AndroidRuntime(715): ERROR: thread attach failed
05-16 14:31:13.698: ERROR/ActivityThread(723): Failed to find provider info for com.google.settings
05-16 14:31:13.987: ERROR/AndroidRuntime(723): Uncaught handler: thread main exiting due to uncaught exception

基本上我的代码是:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    //connect to server

    //get current map scope

    //get media within map scope + a bit

    //init and show map
    setContentView(R.layout.main);
    //add zoom controls
    mapView = (MapView) findViewById(R.id.mapview);

    mapView.setBuiltInZoomControls(true); 


    //add menu
}

例外:

05-16 15:13:05.204: ERROR/AndroidRuntime(726): java.lang.RuntimeException: Unable to start activity     ComponentInfo{org.diretto.client.smartphone.android/org.diretto.client.smartphone.android.AnDiretto}: android.view.InflateException: Binary XML file line #6: Error inflating class java.lang.reflect.Constructor
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.app.ActivityThread.access$1800(ActivityThread.java:112)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.os.Looper.loop(Looper.java:123)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.app.ActivityThread.main(ActivityThread.java:3948)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at java.lang.reflect.Method.invokeNative(Native Method)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at java.lang.reflect.Method.invoke(Method.java:521)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at dalvik.system.NativeStart.main(Native Method)
05-16 15:13:05.204: ERROR/AndroidRuntime(726): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class java.lang.reflect.Constructor
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.view.LayoutInflater.createView(LayoutInflater.java:512)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:564)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:617)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:309)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.app.Activity.setContentView(Activity.java:1626)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at org.diretto.client.smartphone.android.AnDiretto.onCreate(AnDiretto.java:39)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     ... 11 more
05-16 15:13:05.204: ERROR/AndroidRuntime(726): Caused by: java.lang.reflect.InvocationTargetException
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at com.google.android.maps.MapView.(MapView.java:237)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at java.lang.reflect.Constructor.constructNative(Native Method)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at android.view.LayoutInflater.createView(LayoutInflater.java:499)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     ... 21 more
05-16 15:13:05.204: ERROR/AndroidRuntime(726): Caused by: java.lang.IllegalStateException: You are only allowed to have a single MapView in a MapActivity
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at com.google.android.maps.MapActivity.setupMapView(MapActivity.java:180)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at com.google.android.maps.MapView.(MapView.java:279)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     at com.google.android.maps.MapView.(MapView.java:254)
05-16 15:13:05.204: ERROR/AndroidRuntime(726):     ... 25 more

XML文件第6行将是:

<com.google.android.maps.MapView android:id="@+id/mapview" ...

后跟其他XML参数行

2 个答案:

答案 0 :(得分:2)

首先,除非您真正提供答案,否则不要回答您自己的问题。您可以编辑问题以添加新材料,例如更长的堆栈跟踪。

你的例外是:

Caused by: java.lang.IllegalStateException: You are only allowed to have a single MapView in a MapActivity

这是因为您只能在MapView中拥有一个MapActivity,而且显然您有两个或更多。

答案 1 :(得分:1)

我知道你已经很好地解决了这个问题,但我遇到了同样的问题,这里有关于同样问题的笔记,以及我是如何解决这个问题的。

You are only allowed to have a single MapView in a MapActivity

Delete a view and recreate it