【问题标题】:Map activity crashes on invoking it!地图活动在调用它时崩溃!
【发布时间】:2010-10-19 06:19:24
【问题描述】:

我的地图活动在启动时崩溃。我已经包含了所有权限,并且还在一个新的独立地图项目上进行了测试,它与底层代码完美配合。

当我在我的应用程序中加入相同的代码时,它会在调用此活动时立即崩溃。我明天早上有项目提交,请尽快回复

我的地图活动如下

            package com.healthcare.iFind;

            import com.google.android.maps.MapActivity;
            import com.google.android.maps.MapView;
            import com.google.android.maps.MapView.LayoutParams;

            import android.os.Bundle;
            import android.view.View;
            import android.widget.LinearLayout;

            public class MapsActivity extends MapActivity
            {
            MapView mapView;

            /** Called when the activity is first created. */
            @Override
            public void onCreate(Bundle savedInstanceState)
            {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.maps);


            mapView = (MapView) findViewById(R.id.mapView);
            LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom);
            View zoomView = mapView.getZoomControls();

            zoomLayout.addView(zoomView,
            new LinearLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));
            mapView.displayZoomControls(true);

            }

            @Override
            protected boolean isRouteDisplayed() {
            // TODO Auto-generated method stub
            return false;
            }
            }

我的 AndroidManifest.xml 文件:

            <?xml version="1.0" encoding="utf-8"?>
            <manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="com.healthcare.iFind"
            android:versionCode="1"
            android:versionName="1.0.0">
            <application android:icon="@drawable/icon" android:label="@string/app_name">
            <uses-library android:name="com.google.android.maps" />
            <activity android:name=".HomeScreen"
            android:label="@string/app_name">
            <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            </activity>
            <activity android:name="MessageList"></activity>
            <activity android:name="RateDoctor"></activity>
            <activity android:name="RateQuiz"></activity>
            <activity android:name="DetailedDoctor"></activity>
            <activity android:name="DoctorProfile"></activity>
            <activity android:name=".MapsActivity"/>
            </application>

我的 maplayout.xml 文件。

            </manifest>

            <?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="mykey"
            />
            <LinearLayout android:id="@+id/zoom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            />

            </RelativeLayout>

【问题讨论】:

  • 请不要说您的问题很紧急;它不会加快事情的进展。 How To s The Smart Way - catb.org/esr/faqs/smart-questions.html#urgent - 推荐给任何在此类社区网站上寻求帮助的人阅读。
  • 也就是说,你的 logcat 是怎么说的?它应该说明错误发生的位置 - 如果您使用的是 Eclipse,请更改为 DDMS 透视图。
  • 它说,无法解析 Lcom/healthcare/iFind/MapsActivity 的超类;它基本上显示了 NoClassDefFoundError。但是我包含了 Google API + Android 2.2 包,并且在 Eclipse 中的代码中也没有出现错误。我做错了什么?我很抱歉所说的紧迫性,我已经为此工作了一段时间,我只是没有让我的应用程序看起来很愚蠢,因为我不会再这样做了。

标签: android web-applications google-maps crash


【解决方案1】:

就在红线旁边,您的工作区看起来像这样吗?只是为了确保您正在编译 API 而不是常规的 2.2 包。

这段代码在我的模拟器上运行得很好。 (2.2 使用谷歌 API)

以防万一,改变:

<activity android:name=".MapsActivity"/>

进入

<activity android:name=".MapsActivity"/></activity>

它不应该有太大的不同,只是为了保持清单的一致性。

【讨论】:

  • 我的一切都和你说的一模一样,看来我的模拟器出了点问题。但是这个错误不是很奇怪吗?:Lcom/healthcare/iFind/MapsActivity
  • 从 logcat 发布更多信息,它至少没有给出崩溃的地方。将整个 logCat 错误复制到您的原始问题中。您可以尝试删除该 AVD,然后创建一个新的。
  • 我创建了一个新的 AVD,但问题仍然存在。这是 Logcat 中的错误:fpaste.org/B3fX
猜你喜欢
  • 2018-11-26
  • 1970-01-01
  • 1970-01-01
  • 2020-02-23
  • 2013-05-06
  • 2022-01-14
  • 1970-01-01
  • 1970-01-01
  • 2013-10-26
相关资源
最近更新 更多