致命错误而启动应用程序(E / AndroidRuntime(464):致命异常:主) [英] Fatal Error While Starting Application (E/AndroidRuntime(464): FATAL EXCEPTION: main)

查看:202
本文介绍了致命错误而启动应用程序(E / AndroidRuntime(464):致命异常:主)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,大家好我真正的新制作的应用程序,这正在发生,当我开始我的应用程序中的错误。我真的很感激,如果你们中的一个可以请告诉我如何解决这个问题,一步一步的:)谢谢您,请登录:

  08-04 17:02:45.480:D / AndroidRuntime(464):关闭虚拟机
   08-04 17:02:45.480:W / dalvikvm(464):主题ID = 1:螺纹退出与未捕获的异常(组= 0x40015560)
   08-04 17:02:45.499:E / AndroidRuntime(464):致命异常:主要
   08-04 17:02:45.499:E / AndroidRuntime(464):java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.dice.alt / com.dice.alt.DiceAlternativeActivity}:java.lang.ClassCastException:机器人.widget.TextView
   08-04 17:02:45.499:E / AndroidRuntime(464):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
   08-04 17:02:45.499:E / AndroidRuntime(464):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
   08-04 17:02:45.499:E / AndroidRuntime(464):在android.app.ActivityThread.access $ 1500(ActivityThread.java:117)
  08-04 17:02:45.499:E / AndroidRuntime(464):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:931)
  08-04 17:02:45.499:E / AndroidRuntime(464):在android.os.Handler.dispatchMessage(Handler.java:99)
  08-04 17:02:45.499:E / AndroidRuntime(464):在android.os.Looper.loop(Looper.java:123)
  08-04 17:02:45.499:E / AndroidRuntime(464):在android.app.ActivityThread.main(ActivityThread.java:3683)
  08-04 17:02:45.499:E / AndroidRuntime(464):在java.lang.reflect.Method.invokeNative(本机方法)
  08-04 17:02:45.499:E / AndroidRuntime(464):在java.lang.reflect.Method.invoke(Method.java:507)
  08-04 17:02:45.499:E / AndroidRuntime(464):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839)
  08-04 17:02:45.499:E / AndroidRuntime(464):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  08-04 17:02:45.499:E / AndroidRuntime(464):在dalvik.system.NativeStart.main(本机方法)
  08-04 17:02:45.499:E / AndroidRuntime(464):java.lang.ClassCastException:产生的原因android.widget.TextView
  08-04 17:02:45.499:E / AndroidRuntime(464):在com.dice.alt.DiceAlternativeActivity.onCreate(DiceAlternativeActivity.java:20)
  08-04 17:02:45.499:E / AndroidRuntime(464):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  08-04 17:02:45.499:E / AndroidRuntime(464):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  08-04 17:02:45.499:E / AndroidRuntime(464):11 ...更多
  08-04 17:02:48.179:I /处理(464):发送信号。 PID:464 SIG:9< / I>
 

XML:

 < XML版本=1.0编码=UTF-8&GT?;
<滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / Android的:清单
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT>

    <的LinearLayout
        的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:layout_width =match_parent
        机器人:layout_height =409dp
        机器人:方向=垂直>

        <的TextView
            机器人:ID =@ + ID / textView1
            机器人:layout_width =match_parent
            机器人:layout_height =WRAP_CONTENT
            机器人:文本=@字符串/ ndice
            机器人:textAppearance =机器人:ATTR / textAppearanceMedium
            机器人:文字颜色=#4876FF/>

        <的EditText
            机器人:ID =@ + ID / editText1
            机器人:layout_width =match_parent
            机器人:layout_height =WRAP_CONTENT
            机器人:EMS =10
            机器人:inputType =数字
            机器人:文本=@字符串/空>

            <不是requestFocus />
        < /的EditText>

        <的TextView
            机器人:ID =@ + ID / textView2
            机器人:layout_width =match_parent
            机器人:layout_height =WRAP_CONTENT
            机器人:文本=@字符串/ udice
            机器人:textAppearance =机器人:ATTR / textAppearanceMedium
            机器人:文字颜色=#4876FF/>

        <的EditText
            机器人:ID =@ + ID / editText2
            机器人:layout_width =match_parent
            机器人:layout_height =WRAP_CONTENT
            机器人:EMS =10
            机器人:inputType =数字
            机器人:文本=@字符串/空/>

        <按钮
            机器人:ID =@ + ID /按钮1
            机器人:layout_width =match_parent
            机器人:layout_height =WRAP_CONTENT
            机器人:文本=@字符串/结果/>

        <的TextView
            机器人:ID =@ + ID / OP
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:文字颜色=#DC143C
            机器人:layout_weight =0.54
            机器人:文本=@字符串/空
            机器人:textAppearance =:/>中的Andr​​oid ATTR / textAppearanceLarge?

        <的TextView
            机器人:ID =@ + ID / textView3
            机器人:layout_width =match_parent
            机器人:layout_height =WRAP_CONTENT
            机器人:文本=@字符串/ ABJ2
            机器人:textAppearance =机器人:ATTR / textAppearanceSmall
            机器人:文字颜色=#32CD32/>

    < / LinearLayout中>
< /滚动型>
 

解决方案

产生的原因:java.lang.ClassCastException:android.widget.TextView

- 在日志上面这条线表明,有一个例外,而试图投一种类型的变量不兼容的类型

- 您要么试图施放一些不兼容的TextView类型的变量,或者是铸造的TextView为不兼容的类型

例如:

按钮B =(TextView中)findViewById(R.id.mbut);

Hey Guys I Am really new to making apps and this a error that is occurring when i start my app. I would really be thankful if one of you could please tell me how to fix this problem step-by-step :) Thank You, log:

   08-04 17:02:45.480: D/AndroidRuntime(464): Shutting down VM
   08-04 17:02:45.480: W/dalvikvm(464): threadid=1: thread exiting with uncaught exception (group=0x40015560)
   08-04 17:02:45.499: E/AndroidRuntime(464): FATAL EXCEPTION: main
   08-04 17:02:45.499: E/AndroidRuntime(464): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dice.alt/com.dice.alt.DiceAlternativeActivity}: java.lang.ClassCastException: android.widget.TextView
   08-04 17:02:45.499: E/AndroidRuntime(464):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
   08-04 17:02:45.499: E/AndroidRuntime(464):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
   08-04 17:02:45.499: E/AndroidRuntime(464):   at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  08-04 17:02:45.499: E/AndroidRuntime(464):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  08-04 17:02:45.499: E/AndroidRuntime(464):    at android.os.Handler.dispatchMessage(Handler.java:99)
  08-04 17:02:45.499: E/AndroidRuntime(464):    at android.os.Looper.loop(Looper.java:123)
  08-04 17:02:45.499: E/AndroidRuntime(464):    at android.app.ActivityThread.main(ActivityThread.java:3683)
  08-04 17:02:45.499: E/AndroidRuntime(464):    at java.lang.reflect.Method.invokeNative(Native Method)
  08-04 17:02:45.499: E/AndroidRuntime(464):    at java.lang.reflect.Method.invoke(Method.java:507)
  08-04 17:02:45.499: E/AndroidRuntime(464):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  08-04 17:02:45.499: E/AndroidRuntime(464):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  08-04 17:02:45.499: E/AndroidRuntime(464):    at dalvik.system.NativeStart.main(Native Method)
  08-04 17:02:45.499: E/AndroidRuntime(464): Caused by: java.lang.ClassCastException: android.widget.TextView
  08-04 17:02:45.499: E/AndroidRuntime(464):    at com.dice.alt.DiceAlternativeActivity.onCreate(DiceAlternativeActivity.java:20)
  08-04 17:02:45.499: E/AndroidRuntime(464):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  08-04 17:02:45.499: E/AndroidRuntime(464):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  08-04 17:02:45.499: E/AndroidRuntime(464):    ... 11 more
  08-04 17:02:48.179: I/Process(464): Sending signal. PID: 464 SIG: 9</i>'

XML :

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="409dp"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/ndice"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#4876FF" />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="number"
            android:text="@string/empty" >

            <requestFocus />
        </EditText>

        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/udice"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#4876FF" />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="number"
            android:text="@string/empty" />

        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/result" />

        <TextView
            android:id="@+id/op"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#DC143C"
            android:layout_weight="0.54"
            android:text="@string/empty"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/ABJ2"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#32CD32" />

    </LinearLayout>
</ScrollView>

解决方案

Caused by: java.lang.ClassCastException: android.widget.TextView

- This above line in your Log suggests that there is an exception while trying to cast a variable of one type to an incompatible type.

- You are either trying to cast something incompatible to TextView type variable, or you are casting TextView to an incompatible type.

Eg:

Button b = (TextView)findViewById(R.id.mbut);

这篇关于致命错误而启动应用程序(E / AndroidRuntime(464):致命异常:主)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆