`大家好!我尝试在模拟器中显示已经在我的SD卡中的地图,但是当我运行我的程序时,它显示错误:抱歉,proccess意外停止了。 这是我的日志:
10-05 08:12:12.213: W/dalvikvm(1913): Unable to resolve superclass of Lcom/google/ossmap/MainActivity; (975)
10-05 08:12:12.213: W/dalvikvm(1913): Link of class 'Lcom/google/ossmap/MainActivity;' failed
10-05 08:12:12.234: D/AndroidRuntime(1913): Shutting down VM
10-05 08:12:12.234: W/dalvikvm(1913): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
10-05 08:12:12.264: E/AndroidRuntime(1913): FATAL EXCEPTION: main
10-05 08:12:12.264: E/AndroidRuntime(1913): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.google.ossmap/com.google.ossmap.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.google.ossmap.MainActivity" on path: /data/app/com.google.ossmap-2.apk
10-05 08:12:12.264: E/AndroidRuntime(1913): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
10-05 08:12:12.264: E/AndroidRuntime(1913): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-05 08:12:12.264: E/AndroidRuntime(1913): at android.app.ActivityThread.access$600(ActivityThread.java:141)
10-05 08:12:12.264: E/AndroidRuntime(1913): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
10-05 08:12:12.264: E/AndroidRuntime(1913): at android.os.Handler.dispatchMessage(Handler.java:99)
10-05 08:12:12.264: E/AndroidRuntime(1913): at android.os.Looper.loop(Looper.java:137)
10-05 08:12:12.264: E/AndroidRuntime(1913): at android.app.ActivityThread.main(ActivityThread.java:5041)
10-05 08:12:12.264: E/AndroidRuntime(1913): at java.lang.reflect.Method.invokeNative(Native Method)
10-05 08:12:12.264: E/AndroidRuntime(1913): at java.lang.reflect.Method.invoke(Method.java:511)
10-05 08:12:12.264: E/AndroidRuntime(1913): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-05 08:12:12.264: E/AndroidRuntime(1913): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-05 08:12:12.264: E/AndroidRuntime(1913): at dalvik.system.NativeStart.main(Native Method)
10-05 08:12:12.264: E/AndroidRuntime(1913): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.ossmap.MainActivity" on path: /data/app/com.google.ossmap-2.apk
10-05 08:12:12.264: E/AndroidRuntime(1913): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
10-05 08:12:12.264: E/AndroidRuntime(1913): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-05 08:12:12.264: E/AndroidRuntime(1913): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-05 08:12:12.264: E/AndroidRuntime(1913): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
10-05 08:12:12.264: E/AndroidRuntime(1913): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
10-05 08:12:12.264: E/AndroidRuntime(1913): ... 11 more
10-05 08:17:12.404: I/Process(1913): Sending signal. PID: 1913 SIG: 9
我的主要活动:
package com.google.ossmap;
import org.mapsforge.android.maps.MapActivity;
import org.mapsforge.android.maps.MapView;
//import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
public class MainActivity extends MapActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapView mapView = new MapView(this);
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
// mapView.setMapFile("/sdcard/osm.map");
// setContentView(mapView);
mapView.setMapFile(Environment.getExternalStorageDirectory().getAbsolutePath()
+ "/osm.map");
setContentView(mapView);
}
}
我的AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.ossmap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="20" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
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>
</manifest>
有人可以帮忙吗?感谢
答案 0 :(得分:0)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.ossmap.MainActivity" on path: /data/app/com.google.ossmap-2.apk
尝试更改包名称(不明智使用com.google。*)或添加类到清单的完整路径
android:name="com.google.ossmap.MainActivity"