How do I resolve the Rcannot be resolved Android error message?

Asked 1 years ago, Updated 1 years ago, 101 views

I recently downloaded and installed the Android SDK. Make a simple application I tested it.

The code below was automatically generated.

package eu.mauriziopz.gps;

import android.app.Activity;
import android.os.Bundle;

public class ggps extends Activity {
    /** The portion called when activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

But... The following error message appears in Eclipse

R cannot be resolved

At the bottom.

Why are you doing this?

For reference, the main.xml file exists normally in the res/layout/path.

android android-sdk-tools eclipse android-resources

2022-09-22 21:27

1 Answers

We've looked at the problem and found a note in Android documentation as follows.

http://source.android.com/source/using-eclipse.html

*Note: Eclipse sometimes attempts to add the statement "import android.R" to the top of the file that uses resources. Especially when users ask Eclipse to clean up or manage imports. This phenomenon can prevent your work from working normally. Please be careful not to add this wrong import phrase and delete it if you find it.

During the Android sample tutorial, we often use Ctrl + Shift + O shortcuts to organize the import syntax and generate any missing parts. Sometimes this creates an invalid import syntax and hides R.java (a class that is automatically generated when building) to struggle.


2022-09-22 21:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.