Symbol cannot be resolved

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:

.LOGTAG constants cannot be resolved.

Where is my mistake?

Edit Have . The problem was that when I hit Ctrl + Shft + O in Eclipse, he added this line:

import android.provider.SyncStateContract.Constants;

This prevented the compiler from working with its own Constants class.

+5
source share
3 answers

I think there may be another class with a name Constantsthat is automatically imported.

try to use the full name alex.restaurantfinder.Constants.LOGTAG?

+7
source

eclipse . . , .

+1

import alex.restaurantfinder.Constants;

EDIT: Sorry, not necessarily, since the classes are in the same package as follows ...

0
source

All Articles