How to know which error of my android program?

Asked

Viewed 858 times

0

My app is giving an error that I just have no idea how to fix, then I copied the error that gives (on mobile looks like this: "The app'app name' stopped") can help me 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: with.example.messaging for her, PID: 12260 10-14 00:33:41.677: E/Androidruntime(12260): java.lang.Runtimeexception: Unable to start Activity Componentinfo{com.example.messaging for her/com.example.messaging for her . Primeiratela}: java.lang.Classcastexception: android.widget.Button cannot 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 cannot be cast to android.widget.Imageview 10-14 00:33:41.677: E/Androidruntime(12260): at with.example.messaging for her.PrimeiraTela.onCreate(Primeiratela.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

Obs: I don’t know if it does, but I’m using eclipse adt Bundle, but to test the apps using my mobile phone that already has Lollipop... (I can’t use Android Studio, my PC can’t handle.)

Thanks in advance

  • 1

    Bug says you are trying to turn(cast) a Button in Imageview. See the findViewById() of Activity Primeiratela

  • Good afternoon Alan, post the code to see where exactly the problem occurred.

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 on line 32 of the file PrimeiraTela.java.

You tried to make cast (convert) from a class object Button for one of the class ImageView. These two classes are not compatible with each other.

You will probably need to change this line:

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

for that:

Button botao = (Button)findViewById(...);
  • That’s right, you tried to convert an object of one kind into another =)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.