未找到 MapActivity 类中的 Mapview

发布于 2024-10-20 20:28:52 字数 2197 浏览 3 评论 0原文

我在这里看到了具有类似症状的其他线程,但没有一个答案解决了我的问题。我正在关注 Google 地图视图教程 http://developer.android .com/resources/tutorials/views/hello-mapview.html 并严格遵循所有指示,我不断收到此错误.. java.lang.ClassNotFoundException:加载器 dalvik.system 中的 com.goodintechnology.maps.Mymap。 PathClassLoader[/data/app/com.goodintechnology.maps-1.apk]

我已经从头开始很多次了,但是每次,只要我将 Activity 更改为 MapActivity,就会引发错误。应用程序的目标是 Google API 2.2,模拟器是相同的,并且启用了 GPS。我尝试将uses-library 语句放在Applications 语句之前、之后和之中,但这并没有改变任何内容。我什至尝试将声明垂直放在清单中。所以,经过大约 8 个小时的研究,我把它交给了你们所有人。这是代码:

AndroidManifest.xml

<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".Mymap"
              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>

和布局 main.xml

<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="My key that was generated on google is here. trust me"
/>
</LinearLayout>

Mymap 类

package com.goodintechnology.maps;
import com.google.android.maps.MapActivity;
import android.os.Bundle;

public class Mymap 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() {
    // TODO Auto-generated method stub
    return false;
}
}

正如前面提到的,这都是直接来自 Google Map View 教程的。

I've seen other threads here with similar symptoms, but none of the answers solved my problem. I'm following the Google map view tutorial, http://developer.android.com/resources/tutorials/views/hello-mapview.html and following all directions exactly, I keep getting this error .. java.lang.ClassNotFoundException: com.goodintechnology.maps.Mymap in loader dalvik.system.PathClassLoader[/data/app/com.goodintechnology.maps-1.apk]

I've started from scratch many times, but everytime, as soon as I change the Activity to MapActivity, the error is thrown. The app target is Google API 2.2, and the emulator is the same, with GPS enabled. I've tried putting the uses-library statement before, after, and in the Applications statement, but that didn't change anything. I even tried putting the statement vertically in the manifest. So, after about 8 hours messing with this, I put it to all of you. Here's the code:

AndroidManifest.xml

<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".Mymap"
              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>

and the layout main.xml

<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="My key that was generated on google is here. trust me"
/>
</LinearLayout>

And the class Mymap

package com.goodintechnology.maps;
import com.google.android.maps.MapActivity;
import android.os.Bundle;

public class Mymap 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() {
    // TODO Auto-generated method stub
    return false;
}
}

As mentioned this is all straight from Google Map View tutorial.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

我还不会笑 2024-10-27 20:28:52
<uses-library android:name="com.google.android.maps" />

必须在

你说你试过了,但你目前的做法,无论如何都行不通,所以先改变一下。

<uses-library android:name="com.google.android.maps" />

must be within <application> </application>

You said you tried that, but how you currently have it, it wont't work by any chance, so change that first.

雄赳赳气昂昂 2024-10-27 20:28:52

看起来maps.jar 不包含在您的项目文件夹中。

首先,将以下行作为应用程序的子项放入清单文件中,

<uses-library android:name="com.google.android.maps" />

然后右键单击项目文件夹 ->属性->安卓->在项目构建目标中,检查是否仅选中了 Google API 的复选框。
如果没有检查一下。这将在您的项目中添加maps.jar,然后您的项目将了解什么是MapActivity..:)

Looks like maps.jar is not included in your project folder.

First of all put following line as child of application in your manifest file

<uses-library android:name="com.google.android.maps" />

After that right click on your project folder -> Properties -> Android -> In Project Build Target check whether checkbox has been selected for Google API only.
if not check it. this will add maps.jar in your project and then your project will understand what is MapActivity.. :)

爱,才寂寞 2024-10-27 20:28:52

您是否下载了适用于您正在使用的 SDK 版本的 Google API 插件?

Google API 未与标准 SDK 打包在一起。您必须使用 AVD 管理器下载它们。

编辑 - 它表示将添加为 ; 标签。

这意味着将其放在 标记之后 之前的行上。

Did you download the Google API add-on for the SDK version you are using?

The Google APIs are not packaged with the standard SDK. You have to download them using the AVD Manager.

Edit - it says to add the <uses-library ... /> as a child of the <application> tag.

This means to put it on the line after the <application> tag but before </application>.

本王不退位尔等都是臣 2024-10-27 20:28:52

在我创建一个新的 Android 虚拟设备之前,我遇到了完全相同的问题。

确保您创建一个虚拟 Android 设备,其中也包含 Google API。仅在 SDK 中包含 API 并将运行目标设置为包含 Google API 的版本是不够的,您还需要确保您的模拟器虚拟设备还安装了 Android SDK 中的 Google API。

I had the exact same issue until I created a new android virtual device.

Make sure that you create a virtual android device that also has the Google APIs in it also.. just having the APIs in the SDK and setting the run target to a version with Google APIs included isn't enough, you also need to make sure your emulator virtual device has the Google APIs from the Android SDK installed as well.

小伙你站住 2024-10-27 20:28:52

我已经修复了在另一个位置安装 eclipse 并安装 Android 插件 (ADT) 时出现的错误。这对我有用。

I have fixed that error installing eclipse in another location and installing Android plugins (ADT). That worked for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文