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 trialCaleb Seeling
1,189 PointsMy App crashes
When I try to open Interactive Story, the App crashes.This is the Error:
10-23 12:20:57.891 4581-4581/? E/Zygote: v2 10-23 12:20:57.901 4581-4581/? E/Zygote: accessInfo : 0 10-23 12:21:07.591 4581-4581/com.teamtreehouse.interactivestory E/AndroidRuntime: FATAL EXCEPTION: main Process: com.teamtreehouse.interactivestory, PID: 4581 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.teamtreehouse.interactivestory/com.teamtreehouse.interactivestory.ui.StoryActivity}: android.content.res.Resources$NotFoundException: File On your return trip from studying Saturn's rings, you hear a distress signal that seems to be coming from the surface of Mars. It's strange because there hasn't been a colony there in years. Even stranger, it's calling you by name: "Help me, %1$s , you're my only hope." from drawable resource ID #0x7f060022 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3320) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3416) at android.app.ActivityThread.access$1100(ActivityThread.java:229) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:7407) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: android.content.res.Resources$NotFoundException: File On your return trip from studying Saturn's rings, you hear a distress signal that seems to be coming from the surface of Mars. It's strange because there hasn't been a colony there in years. Even stranger, it's calling you by name: "Help me, %1$s , you're my only hope." from drawable resource ID #0x7f060022 at android.content.res.Resources.loadDrawableForCookie(Resources.java:4287) at android.content.res.Resources.loadDrawable(Resources.java:4156) at android.content.res.Resources.getDrawable(Resources.java:2045) at android.content.res.Resources.getDrawable(Resources.java:2027) at android.content.Context.getDrawable(Context.java:464) at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:30) at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:372) at com.teamtreehouse.interactivestory.ui.StoryActivity.loadPage(StoryActivity.java:61) at com.teamtreehouse.interactivestory.ui.StoryActivity.onCreate(StoryActivity.java:55) at android.app.Activity.performCreate(Activity.java:6904) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3267) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3416) at android.app.ActivityThread.access$1100(ActivityThread.java:229) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:7407) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.io.FileNotFoundException: On your return trip from studying Saturn's rings, you hear a distress signal that seems to be coming from the surface of Mars. It's strange because there hasn't been a colony there in years. Even stranger, it's calling you by name: "Help me, %1$s , you're my only hope." at android.content.res.AssetManager.openNonAssetNative(Native Method) at android.content.res.AssetManager.openNonAsset(AssetManager.java:456) at android.content.res.Resources.loadDrawableForCookie(Resources.java:4280) at android.content.res.Resources.loadDrawable(Resources.java:4156) at android.content.res.Resources.getDrawable(Resources.java:2045) at android.content.res.Resources.getDrawable(Resources.java:2027) at android.content.Context.getDrawable(Context.java:464) at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:30) at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:372) at com.teamtreehouse.interactivestory.ui.StoryActivity.loadPage(StoryActivity.java:61) at com.teamtreehouse.interactivestory.ui.StoryActivity.onCreate(StoryActivity.java:55) at android.app.Activity.performCreate(Activity.java:6904) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3267) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3416) at android.app.ActivityThread.access$1100(ActivityThread.java:229) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:7407) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
1 Answer
florentspahiu
Courses Plus Student 120 PointsYou are not setting the nextPage (you are not calling the setNextPage() method), so when you try to call .setText(), your app crashes.
Caleb Seeling
1,189 PointsI don't know what I shall change. Could you give me the code?I changed what I understood you said and corrected the code above...Still, doesn't work.
Caleb Seeling
1,189 PointsCaleb Seeling
1,189 PointsMy Code
StoryActivity:
package com.teamtreehouse.interactivestory.ui;
import android.content.Intent; import android.graphics.drawable.Drawable; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView;
import com.teamtreehouse.interactivestory.R; import com.teamtreehouse.interactivestory.model.Page; import com.teamtreehouse.interactivestory.model.Story;
import static android.R.attr.name;
public class StoryActivity extends AppCompatActivity {
}
Page.java
package com.teamtreehouse.interactivestory.model;
/**
public class Page { private int textId; private int imageId; private Choice choice1; private Choice choice2; private boolean isFinalPage = false;
}
Choice.java
package com.teamtreehouse.interactivestory.model;
/**
public class Choice {
}
Story.java
package com.teamtreehouse.interactivestory.model;
import com.teamtreehouse.interactivestory.R;
import static com.teamtreehouse.interactivestory.R.string.page6;
/**
public class Story {
}