• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

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

 
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Really Thanks Karthik Shiraly
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic