当我运行我的程序时,它是sais:
“不幸的是你的应用程序停止了!”
这是控制台
[2013-04-10 18:36:09 - STO App] ------------------------------
[2013-04-10 18:36:09 - STO App] Android Launch!
[2013-04-10 18:36:09 - STO App] adb is running normally.
[2013-04-10 18:36:09 - STO App] Performing sarah.bodoor.sto.Reminder activity launch
[2013-04-10 18:36:09 - STO App] Automatic Target Mode: Preferred AVD 'STODevice' is available on emulator 'emulator-5554'
[2013-04-10 18:36:11 - STO App] Application already deployed. No need to reinstall.
[2013-04-10 18:36:11 - STO App] Starting activity sarah.bodoor.sto.Reminder on device emulator-5554
[2013-04-10 18:36:14 - STO App] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=sarah.bodoor.sto/.Reminder }
这是logCat
04-10 15:57:00.324: E/Trace(1977): error opening trace file: No such file or directory (2)
04-10 15:57:01.565: E/AndroidRuntime(1977): FATAL EXCEPTION: main
04-10 15:57:01.565: E/AndroidRuntime(1977): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.test2/com.example.test2.MainActivity}: java.lang.RuntimeException: Binary XML file line #16: You must supply a layout_width attribute.
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.os.Looper.loop(Looper.java:137)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-10 15:57:01.565: E/AndroidRuntime(1977): at java.lang.reflect.Method.invokeNative(Native Method)
04-10 15:57:01.565: E/AndroidRuntime(1977): at java.lang.reflect.Method.invoke(Method.java:511)
04-10 15:57:01.565: E/AndroidRuntime(1977): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-10 15:57:01.565: E/AndroidRuntime(1977): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-10 15:57:01.565: E/AndroidRuntime(1977): at dalvik.system.NativeStart.main(Native Method)
04-10 15:57:01.565: E/AndroidRuntime(1977): Caused by: java.lang.RuntimeException: Binary XML file line #16: You must supply a layout_width attribute.
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:5614)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:5756)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:610)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:554)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:56)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.view.LayoutInflater.rInflate(LayoutInflater.java:748)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-10 15:57:01.565: E/AndroidRuntime(1977): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.app.Activity.setContentView(Activity.java:1881)
04-10 15:57:01.565: E/AndroidRuntime(1977): at com.example.test2.MainActivity.onCreate(MainActivity.java:14)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.app.Activity.performCreate(Activity.java:5104)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-10 15:57:01.565: E/AndroidRuntime(1977): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-10 15:57:01.565: E/AndroidRuntime(1977): ... 11 more
即使我做一个简单的项目作为测试,它也给了我相同的信息。我该怎么办?
答案 0 :(得分:0)
您缺少layout_width属性:
引起:java.lang.RuntimeException:二进制XML文件行#16:您必须提供layout_width属性。
在XML文件中添加layout_width属性将解决问题。