Reputation: 53
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>
Upvotes: 0
Views: 1938
Reputation: 33534
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);
Upvotes: 1