首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MapView错误

MapView错误
EN

Stack Overflow用户
提问于 2012-07-16 05:46:53
回答 2查看 102关注 0票数 0

我不知道我做错了什么,因为这不起作用,日志猫显示了一个错误,如下所示。我试过用不同的代码,但还是会出现这个错误。有人能帮我解决这个错误吗?

正在设置的权限:

代码语言:javascript
复制
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

活性

代码语言:javascript
复制
public class Maping extends MapActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);

    }

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

}

XML布局:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map_main"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#6b6a6a"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#333333"
        android:baselineAligned="false"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="0.97"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/mapname"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginBottom="10dp"
                android:layout_marginTop="10dp"
                android:textColor="#ffffff"
                android:textSize="20dp"
                android:text="@string/map" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="#8da635" >

            <Button
                android:id="@+id/addplace"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:background="@drawable/add" />
        </LinearLayout>
    </LinearLayout>

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:apiKey="0lz3OFI5uqLUtnyTYnfbV-lWI6pL5NzX-BUk2dg"
        android:clickable="true"
        android:enabled="true" >
    </com.google.android.maps.MapView>

</LinearLayout>

Logcat

代码语言:javascript
复制
07-16 10:46:49.180: E/AndroidRuntime(364): FATAL EXCEPTION: main
07-16 10:46:49.180: E/AndroidRuntime(364): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{hopscriber.com/hopscriber.com.Maping}: java.lang.ClassNotFoundException: hopscriber.com.Maping in loader dalvik.system.PathClassLoader[/data/app/hopscriber.com-1.apk]
07-16 10:46:49.180: E/AndroidRuntime(364):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
07-16 10:46:49.180: E/AndroidRuntime(364):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-16 10:46:49.180: E/AndroidRuntime(364):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-16 10:46:49.180: E/AndroidRuntime(364):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-16 10:46:49.180: E/AndroidRuntime(364):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-16 10:46:49.180: E/AndroidRuntime(364):  at android.os.Looper.loop(Looper.java:130)
07-16 10:46:49.180: E/AndroidRuntime(364):  at android.app.ActivityThread.main(ActivityThread.java:3683)
07-16 10:46:49.180: E/AndroidRuntime(364):  at java.lang.reflect.Method.invokeNative(Native Method)
07-16 10:46:49.180: E/AndroidRuntime(364):  at java.lang.reflect.Method.invoke(Method.java:507)
07-16 10:46:49.180: E/AndroidRuntime(364):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-16 10:46:49.180: E/AndroidRuntime(364):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-16 10:46:49.180: E/AndroidRuntime(364):  at dalvik.system.NativeStart.main(Native Method)
07-16 10:46:49.180: E/AndroidRuntime(364): Caused by: java.lang.ClassNotFoundException: hopscriber.com.Maping in loader dalvik.system.PathClassLoader[/data/app/hopscriber.com-1.apk]
07-16 10:46:49.180: E/AndroidRuntime(364):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
07-16 10:46:49.180: E/AndroidRuntime(364):  at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
07-16 10:46:49.180: E/AndroidRuntime(364):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
07-16 10:46:49.180: E/AndroidRuntime(364):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
07-16 10:46:49.180: E/AndroidRuntime(364):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-07-16 05:52:59

您尚未在AndroidManifest.xml文件中声明您的活动。

代码语言:javascript
复制
<activity android:name="hopscriber.com.Maping">//here hopscriber.com.Maping==Path of Activity
   <intent-filter>
     <action android:name="android.intent.action.MAIN" />
     <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
 </activity>
票数 0
EN

Stack Overflow用户

发布于 2012-07-16 06:06:29

将下面的行添加到应用程序标记中的清单文件中

代码语言:javascript
复制
<uses-library android:name="com.google.android.maps" />
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11498698

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档