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 Blog Reader Android App Getting Data from the Web Trying Code and Catching Exceptions

James N
James N
17,864 Points

i am getting SO many errors!

i am getting SO many errors! my code (for mainlistactivity.java) is:

package james.blogreader;

import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

import java.net.MalformedURLException;
import java.net.URL;


public class MainListActivity extends ListActivity {

    protected String[] mBlogPostTitles;
    public static final int NUMBER_OF_POSTS = 20;
    public static final String TAG = MainListActivity.class.getSimpleName();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_list);
        try {
            URL blogFeedUrl = new URL("http://blog.teamtreehouse.com/api/get_recent_summary/?count=" + NUMBER_OF_POSTS);
        }
        catch (MalformedURLException e) {
            Log.e(TAG,"Exception caught",e);
        }

        //Toast.makeText(this,getString(R.string.no_items),Toast.LENGTH_LONG).show();



    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main_list, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        return id == R.id.action_settings || super.onOptionsItemSelected(item);
    }
}

my errors are: error: ';' expected ^which appears 4 times error: reached end of file while parsing Error:Execution failed for task ':app:compileDebugJava'.

Compilation failed; see the compiler error output for details.

2 Answers

John Steer-Fowler
PLUS
John Steer-Fowler
Courses Plus Student 11,734 Points

Hi James,

Would you be able to format your code correctly? Only half of your code is formatted using the Markdown Cheatsheet which makes it difficult to read.

If you format the whole code correctly we will be able to help you.

Thanks

James N
James N
17,864 Points

how do i do that?

John Steer-Fowler
John Steer-Fowler
Courses Plus Student 11,734 Points

Half of your code has already been formatted correctly. Refer to the Markdown Cheatsheet when you edit your question for help on formatting your code.

You need to put 3 ``` on the line before and the line after to format the code

James N
James N
17,864 Points

ok done!

Looks like you're missing the closing curly brace for your onCreate method. Try adding that and see if the errors go away.