我正在使用Eclipse作为IDE编写一个Android应用程序,但是在模拟器和手机上都遇到了强制关闭错误。
我只是更改了布局和strings.xml文件,在Eclipse中没有显示任何错误,但是当我尝试在Eclipse模拟器或智能手机上打开应用程序时仍然会出现“强制关闭”。
这是我的布局main.xml。
我希望您能帮助我。编辑:这是日志记录(只复制了错误):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/connect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ButtonConnect" />
<Button
android:id="@+id/device"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/connect"
android:text="@string/ButtonDevice" />
<ImageView
android:id="@+id/joystick_hulle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/joystickhulle"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="30dp"
android:layout_marginLeft="30dp"
android:src="@drawable/joystick_bg" />
<ImageView
android:id="@+id/joystick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/joystick"
android:layout_alignLeft="@+id/joystick_hulle"
android:layout_alignTop="@+id/joystick_hulle"
android:layout_marginLeft="17dp"
android:layout_marginTop="17dp"
android:src="@drawable/joystick" />
<Button
android:id="@+id/M1P"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/device"
android:layout_marginLeft="25dp"
android:layout_toRightOf="@+id/device"
android:text="@string/Pfeilhoch" />
<Button
android:id="@+id/M2P"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/M1P"
android:layout_alignBottom="@+id/M1P"
android:layout_marginLeft="25dp"
android:layout_toRightOf="@+id/M1P"
android:text="@string/Pfeilhoch" />
<Button
android:id="@+id/M3P"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/M2P"
android:layout_alignBottom="@+id/M2P"
android:layout_marginLeft="25dp"
android:layout_toRightOf="@+id/M2P"
android:text="@string/Pfeilhoch" />
<Button
android:id="@+id/M4P"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/M3P"
android:layout_alignBottom="@+id/M3P"
android:layout_marginLeft="25dp"
android:layout_toRightOf="@+id/M3P"
android:text="@string/Pfeilhoch" />
<Button
android:id="@+id/M1N"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/M1P"
android:layout_below="@+id/M1P"
android:layout_marginTop="30dp"
android:text="@string/Pfeilrunter" />
<Button
android:id="@+id/M2N"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/M1N"
android:layout_alignBottom="@+id/M1N"
android:layout_toLeftOf="@+id/M3P"
android:text="@string/Pfeilrunter" />
<Button
android:id="@+id/M5P"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/M1N"
android:layout_marginLeft="25dp"
android:layout_toRightOf="@+id/M4P"
android:text="@string/Pfeilhoch" />
<Button
android:id="@+id/M5N"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/M2N"
android:layout_alignBottom="@+id/M2N"
android:layout_alignLeft="@+id/M5P"
android:text="@string/Pfeilrunter" />
<Button
android:id="@+id/M4N"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/M5N"
android:layout_alignBottom="@+id/M5N"
android:layout_toLeftOf="@+id/M5P"
android:text="@string/Pfeilrunter" />
<Button
android:id="@+id/M3N"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/M2N"
android:layout_alignBottom="@+id/M2N"
android:layout_alignLeft="@+id/M3P"
android:text="@string/Pfeilrunter" />
<TextView
android:id="@+id/M1T"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/M1P"
android:layout_below="@+id/M1P"
android:text="@string/Motor1"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/M2T"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/M1T"
android:layout_alignBottom="@+id/M1T"
android:layout_toLeftOf="@+id/M3P"
android:text="@string/Motor2"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/M3T"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/M2T"
android:layout_alignBottom="@+id/M2T"
android:layout_alignRight="@+id/M3P"
android:text="@string/Motor3"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/M4T"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/M3T"
android:layout_alignBottom="@+id/M3T"
android:layout_alignLeft="@+id/M4P"
android:text="@string/Motor4"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/M5T"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/M4T"
android:layout_alignBottom="@+id/M4T"
android:layout_alignRight="@+id/M5P"
android:text="@string/Motor5"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
我希望您能帮助我。编辑:这是日志记录(只复制了错误):
10-29 13:10:20.245: E/Zygote(32): setreuid() failed. errno: 2
10-29 13:10:29.735: E/Zygote(32): setreuid() failed. errno: 17
10-29 13:10:31.146: E/BatteryService(58): usbOnlinePath not found
10-29 13:10:31.146: E/BatteryService(58): batteryVoltagePath not found
10-29 13:10:31.146: E/BatteryService(58): batteryTemperaturePath not found
10-29 13:10:31.175: E/SurfaceFlinger(58): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
10-29 13:10:37.396: E/EventHub(58): could not get driver version for /dev/input/mouse0, Not a typewriter
10-29 13:10:37.396: E/EventHub(58): could not get driver version for /dev/input/mice, Not a typewriter
10-29 13:10:38.207: E/System(58): Failure starting core service
10-29 13:10:38.207: E/System(58): java.lang.SecurityException
10-29 13:10:38.207: E/System(58): at android.os.BinderProxy.transact(Native Method)
10-29 13:10:38.207: E/System(58): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
10-29 13:10:38.207: E/System(58): at android.os.ServiceManager.addService(ServiceManager.java:72)
10-29 13:10:38.207: E/System(58): at com.android.server.ServerThread.run(SystemServer.java:184)
10-29 13:10:39.256: E/SoundPool(58): error loading /system/media/audio/ui/Effect_Tick.ogg
10-29 13:10:39.266: E/SoundPool(58): error loading /system/media/audio/ui/KeypressStandard.ogg
10-29 13:10:39.266: E/SoundPool(58): error loading /system/media/audio/ui/KeypressSpacebar.ogg
10-29 13:10:39.276: E/SoundPool(58): error loading /system/media/audio/ui/KeypressDelete.ogg
10-29 13:10:39.286: E/SoundPool(58): error loading /system/media/audio/ui/KeypressReturn.ogg
10-29 13:10:41.646: E/ThrottleService(58): Could not open GPS configuration file /etc/gps.conf
10-29 13:10:42.796: E/logwrapper(143): executing /system/bin/tc failed: No such file or directory
10-29 13:10:42.936: E/logwrapper(145): executing /system/bin/tc failed: No such file or directory
10-29 13:10:42.956: E/logwrapper(147): executing /system/bin/tc failed: No such file or directory
10-29 13:10:52.650: E/HierarchicalStateMachine(58): TetherMaster - unhandledMessage: msg.what=3
10-29 13:11:10.122: E/AndroidRuntime(275): FATAL EXCEPTION: main
10-29 13:11:10.122: E/AndroidRuntime(275): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{android.androcrane.htlottakring/android.androcrane.htlottakring.Androcrane}: java.lang.ClassNotFoundException: android.androcrane.htlottakring.Androcrane in loader dalvik.system.PathClassLoader[/data/app/android.androcrane.htlottakring-2.apk]
10-29 13:11:10.122: E/AndroidRuntime(275): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
10-29 13:11:10.122: E/AndroidRuntime(275): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-29 13:11:10.122: E/AndroidRuntime(275): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-29 13:11:10.122: E/AndroidRuntime(275): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-29 13:11:10.122: E/AndroidRuntime(275): at android.os.Handler.dispatchMessage(Handler.java:99)
10-29 13:11:10.122: E/AndroidRuntime(275): at android.os.Looper.loop(Looper.java:123)
10-29 13:11:10.122: E/AndroidRuntime(275): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-29 13:11:10.122: E/AndroidRuntime(275): at java.lang.reflect.Method.invokeNative(Native Method)
10-29 13:11:10.122: E/AndroidRuntime(275): at java.lang.reflect.Method.invoke(Method.java:521)
10-29 13:11:10.122: E/AndroidRuntime(275): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-29 13:11:10.122: E/AndroidRuntime(275): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-29 13:11:10.122: E/AndroidRuntime(275): at dalvik.system.NativeStart.main(Native Method)
10-29 13:11:10.122: E/AndroidRuntime(275): Caused by: java.lang.ClassNotFoundException: android.androcrane.htlottakring.Androcrane in loader dalvik.system.PathClassLoader[/data/app/android.androcrane.htlottakring-2.apk]
10-29 13:11:10.122: E/AndroidRuntime(275): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
10-29 13:11:10.122: E/AndroidRuntime(275): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
10-29 13:11:10.122: E/AndroidRuntime(275): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
10-29 13:11:10.122: E/AndroidRuntime(275): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
10-29 13:11:10.122: E/AndroidRuntime(275): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
10-29 13:11:10.122: E/AndroidRuntime(275): ... 11 more
: E/(): Device disconnected
logcat
输出中看到异常信息。 - Paresh Mayani