Android应用程序强制关闭,不显示任何错误

时间:2012-10-29 13:33:29

标签: java android

我正在使用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>

我希望你能帮助我。

编辑:这是logcat(只是复制了错误):

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

2 个答案:

答案 0 :(得分:1)

这似乎已经发生,因为相应位置缺少类

以下摘自您的日志

 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

所以要确保这个课程位于那里。以避免这个

答案 1 :(得分:-1)

使用相对布局可能会出错,有时xml中元素的顺序很重要,可能会导致崩溃。 擦除布局并使用设计模式重新创建所有组件。