我不知道我做错了什么,因为这不起作用并且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>
logcat的
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)
答案 0 :(得分:0)
您尚未在AndroidManifest.xml文件中声明您的活动。
<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>
答案 1 :(得分:0)
将以下行添加到应用程序标记
中的清单文件中<uses-library android:name="com.google.android.maps" />