找不到MapActivity类中的Mapview

Poo*_*zar 6 android android-mapview

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

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

AndroidManifest.xml
Run Code Online (Sandbox Code Playgroud)

<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>
Run Code Online (Sandbox Code Playgroud)

和布局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>
Run Code Online (Sandbox Code Playgroud)

和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;
}
}
Run Code Online (Sandbox Code Playgroud)

如上所述,这一切都直接来自谷歌地图视图教程.

icy*_*sor 25

<uses-library android:name="com.google.android.maps" />
Run Code Online (Sandbox Code Playgroud)

必须在<application> </ application>中

你说你试过了,但你现在如何拥有它,它不会有任何机会,所以先改变它.


Har*_*had 15

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

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

<uses-library android:name="com.google.android.maps" />
Run Code Online (Sandbox Code Playgroud)

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


Mat*_*lis 4

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

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

编辑- 它说将 添加<uses-library ... />作为标签的子项<application>

这意味着将其放在标记之后<application>、之前的行中</application>