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 Build an Interactive Story App The Rest of the Story Loading Additional Pages

New pages won't load. Error in Logcat says: E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaa06d6e0

Hey all! There's not much to it besides that. The code worked fine before up until this point.

I tried using different virtual devices, since I found that a similar error was fixed by doing that, but it didn't help. Here's my code from StoryActivity:

public class StoryActivity extends AppCompatActivity {

public static final String TAG = StoryActivity.class.getSimpleName();

private String name;
private Story story;
private ImageView storyImageView;
private TextView storyTextView;
private Button choice1Button;
private Button choice2Button;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_story);

    storyImageView = (ImageView)findViewById(R.id.storyImageView);
    storyTextView = (TextView)findViewById(R.id.storyTextView);
    choice1Button = (Button)findViewById(R.id.choice1Button);
    choice2Button = (Button)findViewById(R.id.choice2Button);

    Intent intent = getIntent();
    name = intent.getStringExtra(getString(R.string.key_name));
    if (name == null || name.isEmpty()) {
        name = "Friend";
    }
    Log.d(TAG, name);

    story = new Story();
    loadPage(0);


}

private void loadPage(int pageNumber) {
    final Page page = story.getPage(0);

    Drawable image = ContextCompat.getDrawable(this, page.getImageID());
    storyImageView.setImageDrawable(image);

    String pageText = getString(page.getTextId());
    // Add name if placeholder is included, won't add if not
    pageText = String.format(pageText, name);
    storyTextView.setText(pageText);

    choice1Button.setText(page.getChoice1().getTextId());
    choice1Button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int nextPage = page.getChoice1().getNextPage();
            loadPage(nextPage);
        }
    });

    choice2Button.setText(page.getChoice2().getTextId());
    choice2Button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int nextPage = page.getChoice2().getNextPage();
            loadPage(nextPage);
        }
    });

}

}