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.
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.
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.
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
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With