How to know which error in my android program? [closed]

0

My app is giving a bug that I simply have no idea how to fix it, then I copied the error it gives (on mobile phone it looks like: "app app name 'stopped') can help me to identify the problem ?

  

10-14 00: 33: 41.677: E / AndroidRuntime (12260): FATAL EXCEPTION: main   10-14 00: 33: 41.677: E / AndroidRuntime (12260): Process:   com.example.message for it, PID: 12260 10-14 00: 33: 41.677:   E / AndroidRuntime (12260): java.lang.RuntimeException: Unable to start   activity   ComponentInfo {com.example.messagetoward / com.example.messageforthis   .First Window}:   java.lang.ClassCastException: android.widget.Button can not be cast to   android.widget.ImageView 10-14 00: 33: 41.677: E / AndroidRuntime (12260):     at   android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2358)

     

10-14 00: 33: 41.677: E / AndroidRuntime (12260): at   android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2420)

     

10-14 00: 33: 41.677: E / AndroidRuntime (12260): at   android.app.ActivityThread.access $ 900 (ActivityThread.java:154) 10-14

     

00: 33: 41.677: E / AndroidRuntime (12260): at   android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1321)

     

10-14 00: 33: 41.677: E / AndroidRuntime (12260): at   android.os.Handler.dispatchMessage (Handler.java:102) 10-14

     

00: 33: 41.677: E / AndroidRuntime (12260): at   android.os.Looper.loop (Looper.java:135) 10-14

     

00: 33: 41.677: E / AndroidRuntime (12260): at   android.app.ActivityThread.main (ActivityThread.java:5294) 10-14

     

00: 33: 41.677: E / AndroidRuntime (12260): at   java.lang.reflect.Method.invoke (Native Method) 10-14   00: 33: 41.677: E / AndroidRuntime (12260): at   java.lang.reflect.Method.invoke (Method.java:372) 10-14   00: 33: 41.677: E / AndroidRuntime (12260): at   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:904)   10-14 00: 33: 41.677: E / AndroidRuntime (12260): at   com.android.internal.os.ZygoteInit.main (ZygoteInit.java:699) 10-14   00: 33: 41.677: E / AndroidRuntime (12260): Caused by:   java.lang.ClassCastException: android.widget.Button can not be cast to   android.widget.ImageView 10-14 00: 33: 41.677: E / AndroidRuntime (12260):     at   com.example.messageto her.FirstBook.onCreate (First.java:32)   10-14 00: 33: 41.677: E / AndroidRuntime (12260): at   android.app.Activity.performCreate (Activity.java:5990) 10-14   00: 33: 41.677: E / AndroidRuntime (12260): at   android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1106)   10-14 00: 33: 41.677: E / AndroidRuntime (12260): at   android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2311)   10-14 00: 33: 41.677: E / AndroidRuntime (12260): ... 10 more

I do not know if it affects, but I'm using the eclipse adt bundle, but to test the apps to using my cell phone that already has the lollipop ... (I can not use Android Studio, my PC can not handle it.)

Thank you in advance

    
asked by anonymous 26.10.2015 / 12:22

1 answer

3
Caused by:
java.lang.ClassCastException: android.widget.Button cannot be cast to
android.widget.ImageView 10-14 00:33:41.677: E/AndroidRuntime(12260):
at com.example.mensagemparaela.PrimeiraTela.onCreate(PrimeiraTela.java:32)

The cause is at line 32 of file PrimeiraTela.java .

You tried to cast (convert) an object of class Button to one of class ImageView . These two classes are not compatible with each other.

You'll probably need to change this line:

ImageView botao = (ImageView)findViewById(...);

by this:

Button botao = (Button)findViewById(...);
    
26.10.2015 / 12:31