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 trialKate Dougherty
8,334 PointsApp stopping on emulator before it even opens
I had a lot of problems getting my app to build. I put the code through an XML validator and ultimate added a closing </EditText> tag. I also tried adding the same final line that appears in the video, but that generated errors, and the closing EditText didn't. I got the project to build successfully, but now it's stopping on the emulator before it even gets started.
<?xml version="1.0" encoding="utf-8"?> <EditText xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.katedoughertywriter.interactivestory.MainActivity">
<ImageView
android:contentDescription="Signals from Mars title image"
android:id="@+id/titleImageView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/main_title"/>
<Button
android:id="@+id/startButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:text="START YOUR ADVENTURE"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<EditText
android:id="@+id/nameEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:ems="10"
android:hint="Enter your name"
android:inputType="textCapWords|textPersonName"
android:maxLength="30"
app:layout_constraintBottom_toTopOf="@+id/startButton"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
</EditText>
3 Answers
Sachin Jayaram
5,461 PointsTry to look at your console output and see what error you are getting, there are many exceptions that might cause the app to stop. It would be helpful if you attached the logs as well. Also look at the code they have written and compare it with yours. Usually they have the zip file in the download section.
Zach Rebstock
4,632 PointsIf this is the Android Story App course:
I had the same issue because my Story was creating Pages[] at index 1, not 0, and that would crash the app. If you could post your Java code, that would help.
Post your LogCat errors too :)
Kate Dougherty
8,334 PointsI actually fixed this by downloading the project files and matching up the code. I think the problem was that I updated to a new version of Android Studio in the middle of the project, and it ended up mis-matching a couple of tags.
Sachin Jayaram
5,461 PointsGlad you figured it out. Happy coding.