在android eclipse中意外停止
Posted
技术标签:
【中文标题】在android eclipse中意外停止【英文标题】:stopped unexpectedly in android eclipse 【发布时间】:2014-11-28 12:36:25 【问题描述】:有人可以帮助我吗?我想在我的安卓屏幕上显示一张地图,但是当我尝试运行我的模拟器时,我收到了错误:“意外停止,请重试”。 我使用日食。 这是我的日志:
10-03 12:20:48.578: W/dalvikvm(1643): Unable to resolve superclass of Lcom/formation/gmaps/MainActivity; (976)
10-03 12:20:48.578: W/dalvikvm(1643): Link of class 'Lcom/formation/gmaps/MainActivity;' failed
10-03 12:20:48.597: D/androidRuntime(1643): Shutting down VM
10-03 12:20:48.597: W/dalvikvm(1643): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
10-03 12:20:48.627: E/AndroidRuntime(1643): FATAL EXCEPTION: main
10-03 12:20:48.627: E/AndroidRuntime(1643): java.lang.RuntimeException: Unable to instantiate activity ComponentInfocom.formation.gmaps/com.formation.gmaps.MainActivity: java.lang.ClassNotFoundException: Didn't find class "com.formation.gmaps.MainActivity" on path: /data/app/com.formation.gmaps-1.apk
10-03 12:20:48.627: E/AndroidRuntime(1643): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
10-03 12:20:48.627: E/AndroidRuntime(1643): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-03 12:20:48.627: E/AndroidRuntime(1643): at android.app.ActivityThread.access$600(ActivityThread.java:141)
10-03 12:20:48.627: E/AndroidRuntime(1643): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
10-03 12:20:48.627: E/AndroidRuntime(1643): at android.os.Handler.dispatchMessage(Handler.java:99)
10-03 12:20:48.627: E/AndroidRuntime(1643): at android.os.Looper.loop(Looper.java:137)
10-03 12:20:48.627: E/AndroidRuntime(1643): at android.app.ActivityThread.main(ActivityThread.java:5041)
10-03 12:20:48.627: E/AndroidRuntime(1643): at java.lang.reflect.Method.invokeNative(Native Method)
10-03 12:20:48.627: E/AndroidRuntime(1643): at java.lang.reflect.Method.invoke(Method.java:511)
10-03 12:20:48.627: E/AndroidRuntime(1643): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-03 12:20:48.627: E/AndroidRuntime(1643): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-03 12:20:48.627: E/AndroidRuntime(1643): at dalvik.system.NativeStart.main(Native Method)
10-03 12:20:48.627: E/AndroidRuntime(1643): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.formation.gmaps.MainActivity" on path: /data/app/com.formation.gmaps-1.apk
10-03 12:20:48.627: E/AndroidRuntime(1643): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
10-03 12:20:48.627: E/AndroidRuntime(1643): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-03 12:20:48.627: E/AndroidRuntime(1643): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-03 12:20:48.627: E/AndroidRuntime(1643): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
10-03 12:20:48.627: E/AndroidRuntime(1643): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
10-03 12:20:48.627: E/AndroidRuntime(1643): ... 11 more
谢谢!
【问题讨论】:
您能列出在出现此错误之前您已完成的步骤吗? 【参考方案1】:检查你的日志,上面写着这个,
Didn't find class "com.formation.gmaps.MainActivity" on path: /data/app/com.formation.gmaps-1.apk
所以请检查你的包 com.formation.gmaps ,它是否包含 这个 MainaActivity 并检查您的清单以确认
【讨论】:
【参考方案2】:在您的设备而不是模拟器中尝试它有时可以在设备上正常工作。
【讨论】:
【参考方案3】:正如日志所说,链接 MainActivity 时出错,因此那里的一些代码可能有用
【讨论】:
【参考方案4】:非常感谢您的回答! 是的!我的包 com.formation.gmaps 包含这个 MainActivity,这是我的 androidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.formation.gmaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="20" />
<uses-permission android:name="android.permission.WRITE_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>
我的主要活动:
package com.formation.gmaps;
import android.os.Bundle;
import android.os.Environment;
import java.io.File;
import org.mapsforge.android.maps.MapActivity;
import org.mapsforge.android.maps.MapView;
@SuppressWarnings("unused")
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(Environment.getExternalStorageDirectory().getAbsolutePath()
+ "/map.map");
setContentView(mapView);
那么我应该买一个新的包裹吗?
【讨论】:
以上是关于在android eclipse中意外停止的主要内容,如果未能解决你的问题,请参考以下文章
在 prepareForSegue 中意外发现 nil IBOutlet