尝试启动新活动时Android应用程序崩溃

时间:2013-06-27 12:38:30

标签: android android-intent android-activity forceclose

我正在尝试启动一个新的Activity,android。这是创建以下错误。 注意:我已更新清单

中的新活动

logcat的

06-27 18:00:39.543: D/AndroidRuntime(908): Shutting down VM
06-27 18:00:39.543: W/dalvikvm(908): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
06-27 18:00:39.563: E/AndroidRuntime(908): FATAL EXCEPTION: main
06-27 18:00:39.563: E/AndroidRuntime(908): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dipl.smpm.smpm/com.dipl.smpm.smpm.UpdateTask}: android.view.InflateException: Binary XML file line #15: Error inflating class button
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.os.Looper.loop(Looper.java:123)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.app.ActivityThread.main(ActivityThread.java:4627)
06-27 18:00:39.563: E/AndroidRuntime(908):  at java.lang.reflect.Method.invokeNative(Native Method)
06-27 18:00:39.563: E/AndroidRuntime(908):  at java.lang.reflect.Method.invoke(Method.java:521)
06-27 18:00:39.563: E/AndroidRuntime(908):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-27 18:00:39.563: E/AndroidRuntime(908):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-27 18:00:39.563: E/AndroidRuntime(908):  at dalvik.system.NativeStart.main(Native Method)
06-27 18:00:39.563: E/AndroidRuntime(908): Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class button
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-27 18:00:39.563: E/AndroidRuntime(908):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.app.Activity.setContentView(Activity.java:1647)
06-27 18:00:39.563: E/AndroidRuntime(908):  at com.dipl.smpm.smpm.UpdateTask.onCreate(UpdateTask.java:11)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
06-27 18:00:39.563: E/AndroidRuntime(908):  ... 11 more
06-27 18:00:39.563: E/AndroidRuntime(908): Caused by: java.lang.ClassNotFoundException: android.view.button in loader dalvik.system.PathClassLoader[/data/app/com.dipl.smpm.smpm-2.apk]
06-27 18:00:39.563: E/AndroidRuntime(908):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
06-27 18:00:39.563: E/AndroidRuntime(908):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
06-27 18:00:39.563: E/AndroidRuntime(908):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.view.LayoutInflater.createView(LayoutInflater.java:466)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
06-27 18:00:39.563: E/AndroidRuntime(908):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
06-27 18:00:39.563: E/AndroidRuntime(908):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)

1 个答案:

答案 0 :(得分:5)

您似乎已将xml布局中的按钮定义为

     <button
       android:layout_width="fill_parent"
       ..........

                  />

但你必须写一个大写b

     <Button
        android:layout_width="fill_parent"
         ............

                   />

这就是错误消息

中的行
    Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class button  <--- You wrote button, but it has to be Button