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

Ricky Sparks
Ricky Sparks
22,249 Points

Android Ribbit App has one simple error that says 'class or interface expected' (screenshot available)

Click for screenshot below to view image

http://i.imgur.com/Xnjd7uB.png?1

Dan Johnson
Dan Johnson
40,533 Points

Could you post all the code for FriendsFragment.java?

If I were to guess based on the error marker, you might have an extra opening brace somewhere.

Ricky Sparks
Ricky Sparks
22,249 Points

`` package com.patriothighschool.rickyjames1750.ribbit;

import java.util.List;

import android.app.AlertDialog; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter;

import com.parse.FindCallback; import com.parse.ParseException; import com.parse.ParseQuery; import com.parse.ParseRelation; import com.parse.ParseUser;

public class FriendsFragment extends ListFragment {

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

protected ParseRelation<ParseUser> mFriendsRelation;
protected ParseUser mCurrentUser;
protected List<ParseUser> mFriends;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_friends,
            container, false);

    return rootView;
}

@Override
public void onResume() {
    super.onResume();

    mCurrentUser = ParseUser.getCurrentUser();
    mFriendsRelation = mCurrentUser.getRelation(ParseConstants.KEY_FRIENDS_RELATION);

    getActivity().setProgressBarIndeterminateVisibility(true);

    ParseQuery<ParseUser> query = mFriendsRelation.getQuery();
    query.addAscendingOrder(ParseConstants.KEY_USERNAME);
    query.findInBackground(new FindCallback<ParseUser>() {
        @Override
        public void done(List<ParseUser> friends, ParseException e) {
            getActivity().setProgressBarIndeterminateVisibility(false);

            if (e == null) {
                mFriends = friends;

                String[] usernames = new String[mFriends.size()];
                int i = 0;
                for(ParseUser user : mFriends) {
                    usernames[i] = user.getUsername();
                    i++;
                }
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(
                        getListView().getContext(),
                        android.R.layout.simple_list_item_1,
                        usernames);
                setListAdapter(adapter);
            }
            else {
                Log.e(TAG, e.getMessage());
                AlertDialog.Builder builder = new AlertDialog.Builder(getListView().getContext());
                builder.setMessage(e.getMessage())
                        .setTitle(R.string.error_title)
                        .setPositiveButton(android.R.string.ok, null);
                AlertDialog dialog = builder.create();
                dialog.show();
            }
        }
    });
}

} ``

Dan Johnson
Dan Johnson
40,533 Points

Checked against the start for the Ribbit Design project and the code all looks fine. Do you have the Parse 1.3.9 jar in the libs directory and is it listed as a dependency in the (app) Gradle file?

Ricky Sparks
Ricky Sparks
22,249 Points

Parse 1.3.9 jar in the libs directory ... is missing is it listed as a dependency in the (app) Gradle file? ....not sure if i'm missing a gradle file

new screenshot 2 http://i.imgur.com/r26jr2C.png?1

Dan Johnson
Dan Johnson
40,533 Points

My best guess would be that it's an issue with the version of Parse. I'll update my version of Android Studio to check any issues with importing though.

Ricky Sparks
Ricky Sparks
22,249 Points

Did you have something similar?

Dan Johnson
Dan Johnson
40,533 Points

Sorry for the late response,

I tested importing with Android Studio 1.1 using the starting project files for the "Implementing Designs for Android" course. Using the defaults generated an app that ran without modification.

If you're moving on to this course and haven't changed a lot of code from the previous course, it may just be easier to download the project files from the "Download" section below the second video, then using File -> Import Project... to convert it to an Android Studio project (don't forget to change the Parse application ID and client key).

If you need to use the existing project files that you have locally, you could push it up to GitHub or some other sharing service and I could try to mess with it from there. The error implies it can't find some definition so that's why I was thinking it had to do with Gradle or the Parse version.

1 Answer