Jan
Jan

Reputation: 13

Can't find class in the same package

Within MainActivity.java I wrote a setOnClickListener method. Inside onClick, there is the following code:

@Override
public void onClick(View view) {
    DialogShowNote dialog = new DialogShowNote();
    dialog.sendNoteSelected();
    dialog.show(getFragmentManager(), "123");
}

DialogShowNote is a class that extends DialogFramgment and is contained in the smae Java package. I get the error

"Cannot resolve symbol "DialogShowNote"

Does anyone have a clue?

Upvotes: 0

Views: 2487

Answers (2)

nairsk
nairsk

Reputation: 71

Delete the .idea file and restart the IntelliJ/Android Studio.

Upvotes: 1

wseme
wseme

Reputation: 835

Try the following:

  1. Check that the class name and the file name are the same, look for typos.
  2. Check imported classes, ensure it is being imported correctly into your class.
  3. Check the file paths, ensure the paths are correct or if the package is different.
  4. Do a reclean/'gradle sync' and recompile to ensure there is no garbage.
  5. Check class access, ensure it is public.
  6. Check the constructor, ensure this exists and is public.

Good luck.

Upvotes: 1

Related Questions