• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The Application has stopped unexpectedly please try again {com.android.internal.os.ZygoteInit$Meth}

 
Rohit Gaikwad
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying my first Android app with 2 text and 2 Buttons
the app is working fine and also getting loaded in {AVD} but when i click one of the button it stops saying "stopped unexpectedly please try again"

The XML code is
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


The Main Activity java code is
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



I thought the error is due to the Android Version i am using on Emulator but even tried it with 5.0.1 and 5.1.1 and also with target AVD 2.2
But still the same error

Thanks in advance
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's because TextView.setText(int) doesn't do what you think it does. From http://developer.android.com/reference/android/widget/TextView.html#setText(int) , the int argument is treated as a resource ID of a string resource. When you set setText(count), android goes looking for a string resource with ID=value of count, doesn't find it and crashes. The logcat exception trace will have revealed that.

Use Integer.toString(count) to set the text.
...
And never assume anything about an API. Javadocs are your friend ;)
 
Rohit Gaikwad
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really Thanks Karthik Shiraly
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic