Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

java.lang.RuntimeException: Unable to instantiate activity (own project)

So I finished the new course in the Android section and as Ben suggested I tried to make another app where an user inputs some data and the app takes him to another activity. My idea was this: the user logins -> it takes him to a new activity with 3 buttons (representing 3 buildings) -> each one has 2 buttons ("back" and "do nothing").

The app itself does absolutely nothing but I want to practice on the things I learned. So after I wrote my code, I tried to launch the app. I enter my name and password and when I click the button below it just says that my app has stopped working and crashes. Below is my code for both of my activities, my manifest and my logcat. All this is in pastebin, since this post would be too huge.

Main Activity -> http://pastebin.com/kHyHp1WC

Second Activity -> http://pastebin.com/zdTZvrtk

Manifest -> http://pastebin.com/crkpG94d

LogCat -> http://pastebin.com/Adeak3Q0

Can you post your City model?

ArrayIndexOutOfBoundsException means you are trying to access an array index that doesn't exist and array index start at 0.

Ex.

String[] name = {"A", "B", "C"};
int length = name.length;
System.out.println(name[length - 1]);  // C
System.out.println(name[length]);      // ArrayIndexOutBoundsException

Thank you for your reply. I saw what you mean and fixed it. Haven't noticed it said the problem is in the "city" class.