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 a Simple Android App (retired 2014) Pretty Little Things Animating the Crystal Ball

Compiler Error

Receive a complier error for the following code that i dont quite understand

''' public void animateFrog(){ ImageView frogImage = (ImageView) findViewById(R.id.frog); AnimationDrawable jumpAnimation = (AnimationDrawable) frogImage.getDrawable(); if ( jumpAnimation.isRunning() ){ } } '''

2 Answers

Paul Stevens
Paul Stevens
4,125 Points

Hello,

Your code seems to be correct. I have redone the challenge and will paste both your code and my code here in java format to see if anything stands out.

Your code:

public void animateFrog(){ 
     ImageView frogImage = (ImageView) findViewById(R.id.frog);
     AnimationDrawable jumpAnimation = (AnimationDrawable)frogImage.getDrawable(); 
     if ( jumpAnimation.isRunning() ){

     }
}

My code:

public void animateFrog() {
    ImageView frogImage = (ImageView) findViewById(R.id.frog);
    AnimationDrawable jumpAnimation = (AnimationDrawable) frogImage.getDrawable();
    if (jumpAnimation.isRunning()) {

    }  
}

Other than slightly different spacing I can't see anything that should stop it working. Have had a busy day, so I may be missing something :D I know the code I wrote passes the challenge though as I tested it.

Hope this helps,

Paul :)

Sander de Wijs
PLUS
Sander de Wijs
Courses Plus Student 22,267 Points

I'm also having trouble with this challenge. The compiler returns this error message: ./com/example/MainActivity.java:22: reached end of file while parsing } ^ 1 error

This is when using Paul's code above.