0

我不知道我做错了什么,因为这不起作用并且 log cat 显示错误,如下所示。我尝试了不同的代码,但仍然出现此错误。有人会帮我解决这个错误吗?

正在设置的权限:

<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" />

活动

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 布局:

<?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>

日志猫

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)
4

2 回答 2

0

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

<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>
于 2012-07-16T05:52:59.163 回答
0

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

<uses-library android:name="com.google.android.maps" />
于 2012-07-16T06:06:29.620 回答