Search code examples
javaandroidandroid-activityandroid-studiolistactivity

Error: anonymous class is not abstract and does not override abstract method


Please, I am getting an error in the method below whenever I try to build my android project.

Method :

query.findInBackground(new FindCallback() {
            @Override
            public void done(List<ParseObject> objects, ParseException e) {
                mProgressBar.setVisibility(View.INVISIBLE);

                if (e == null) {
                    objects = removeCurrentUser(objects);
                    mUsers = objects.toArray(new ParseObject[0]);

                    // Get user relations
                    ParseRelation userRelations = ParseUser.getCurrentUser().getRelation("UserRelation");
                    userRelations.getQuery().findInBackground(new FindCallback() {
                        @Override
                        public void done(List<ParseObject> results, ParseException e) {
                            if (e == null) {
                                UsersAdapter adapter = new UsersAdapter(SelectUsersActivity.this, mUsers, new ArrayList<ParseObject>(results));
                                setListAdapter(adapter);
                            }
                            else {
                                Log.e(TAG, "Exception caught!", e);
                            }
                        }
                    });
                }
                else {
                    // Something went wrong.
                    Toast.makeText(SelectUsersActivity.this, "Sorry, there was an error getting users!", Toast.LENGTH_LONG).show();
                }
            }
        }//
         );

Errors :

Error:(46, 45) error: is not abstract and does not override abstract method done(List,ParseException) in FindCallback

Error:(48, 16) error: name clash: done(List,ParseException) in and done(List,ParseException) in FindCallback have the same erasure, yet neither overrides the other where T is a type-variable: T extends ParseObject declared in interface FindCallback

Here is Screenshot


Solution

  • You haven't parameterized your anonymous FindCallback subclass, so your done signature doesn't match the FindCallback#done signature because the done signature in the un-parameterized version is done(List<Object>results, ParseException e).

    To fix it, parameterize it:

    userRelations.getQuery().findInBackground(new FindCallback<ParseObject>() {
    // Add ---------------------------------------------------^^^^^^^^^^^^^