Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Simple Android App Basic Android Programming Adding the OnClick Method

Gavin Bowen
Gavin Bowen
5,898 Points

android will not run app

what happens in logcat: 02-15 10:27:35.203 5113-5113/? E/Zygote: MountEmulatedStorage() 02-15 10:27:35.213 5113-5113/? E/Zygote: v2 02-15 10:27:35.213 5113-5113/? I/libpersona: KNOX_SDCARD checking this for 10186 02-15 10:27:35.213 5113-5113/? I/libpersona: KNOX_SDCARD not a persona 02-15 10:27:35.213 5113-5113/? I/SELinux: Function: selinux_compare_spd_ram, SPD-policy is existed. and_ver=SEPF_GT-I9505_5.0.1 ver=27 02-15 10:27:35.213 5113-5113/? I/SELinux: Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_GT-I9505_5.0.1-1_0039 02-15 10:27:35.213 5113-5113/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL 02-15 10:27:35.243 5113-5113/? I/art: Late-enabling -Xcheck:jni 02-15 10:27:35.293 5113-5128/? E/art: Failed writing handshake bytes (-1 of 14): Broken pipe 02-15 10:27:35.293 5113-5128/? I/art: Debugger is no longer active 02-15 10:27:35.333 5113-5113/? D/ResourcesManager: creating new AssetManager and set to /data/app/com.gtapplications.funfacts-2/base.apk 02-15 10:27:35.494 5113-5113/? D/AndroidRuntime: Shutting down VM 02-15 10:27:35.494 5113-5113/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.gtapplications.funfacts, PID: 5113 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gtapplications.funfacts/com.gtapplications.funfacts.FunFactsActivity}: java.lang.ClassCastException: android.support.v7.widget.AppCompatTextView cannot be cast to android.widget.Button at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2702) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767) at android.app.ActivityThread.access$900(ActivityThread.java:177) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5951) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) Caused by: java.lang.ClassCastException: android.support.v7.widget.AppCompatTextView cannot be cast to android.widget.Button at com.gtapplications.funfacts.FunFactsActivity.onCreate(FunFactsActivity.java:22) at android.app.Activity.performCreate(Activity.java:6289) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)  at android.app.ActivityThread.access$900(ActivityThread.java:177)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:5951)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)  02-15 10:27:39.397 5113-5113/com.gtapplications.funfacts I/Process: Sending signal. PID: 5113 SIG: 9

1 Answer

Kourosh Raeen
Kourosh Raeen
23,732 Points

I see a ClassCastException in the logcat complaining that you are trying to cast a TextView to a Button. See where in your code you are doing that.