aperture
aperture

Reputation: 2895

java.lang.ClassCastException in Android

Started getting a ClassCastException in a widget I've been working on that I'm not sure what it's having an issue with. I haven't modified the configure class, nor the configure layout, yet I've started getting a stack trace leading back to my configure class after modifying the main layout

E/AndroidRuntime( 2010): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.metatroid.minimal.music/
com.metatroid.minimal.music.Configure}: java.lang.ClassCastException: android.widget.RadioButton
E/AndroidRuntime( 2010):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
E/AndroidRuntime( 2010):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime( 2010):        at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime( 2010):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime( 2010):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2010):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 2010):        at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 2010):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2010):        at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 2010):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 2010):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 2010):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2010): Caused by: java.lang.ClassCastException: android.widget.RadioButton
E/AndroidRuntime( 2010):        at com.metatroid.minimal.music.Configure.onCreate(Configure.java:39)
E/AndroidRuntime( 2010):        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 2010):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime( 2010):        ... 11 more

Reverting my changes causes the issue to go away, but I'm not doing anything with this file, nor am I modifying any RadioButtons...so what the hell? The line #39 of Configure.java is

EditText prv = (EditText) findViewById(R.id.previous_input);

I don't see how that ties into anything. And the only changes I am making to the entire project are changing some TextViews into Buttons in my main.xml layout which is not referenced in Configure.java. Reverting the Button back to TextView makes the error go away. What causes a "ClassCastException" and what could possibly be going on here?

Upvotes: 2

Views: 1575

Answers (1)

Nikola Despotoski
Nikola Despotoski

Reputation: 50578

Try clean your project. Previously you had RadioButton.

Upvotes: 8

Related Questions