Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symbol cannot be resolved

Tags:

java

android

Android Java project, minimal code to reproduce the problem:

Constants.java:

package alex.restaurantfinder;

public class Constants {
    public static final String LOGTAG = "...";
}

ReviewCriteria.java:

package alex.restaurantfinder;
import android.app.Activity;

public class ReviewCriteria extends Activity {
    static String s = Constants.LOGTAG;            // error
}

Error message:

Constants.LOGTAG cannot be resolved.

Where is my error?

Edit. The problem was, when I pressed Ctrl+Shft+O in Eclipse, it added this line:

import android.provider.SyncStateContract.Constants;

It prevented compiler to work with my own Constants class.

like image 357
Alex F Avatar asked Nov 16 '11 10:11

Alex F


People also ask

How do I fix error Cannot find symbol?

In the above program, "Cannot find symbol" error will occur because “sum” is not declared. In order to solve the error, we need to define “int sum = n1+n2” before using the variable sum.

What is Cannot resolve symbol in Java?

The cannot find symbol error, also found under the names of symbol not found and cannot resolve symbol , is a Java compile-time error which emerges whenever there is an identifier in the source code which the compiler is unable to work out what it refers to.


1 Answers

I think there might be another Class called Constants that is imported automatically.

can you try using the fully qualified name alex.restaurantfinder.Constants.LOGTAG?

like image 174
Liviu T. Avatar answered Oct 03 '22 04:10

Liviu T.