0

I have found numerous posts about this issue and read through them. I have tried rebuilding the project, do a project clean and a gradle-clean as well still didn't help.

Perhaps there's something wrong with my codes?

The error I get lies in "setContentView(R.layout.read_comments)" cannot resolve symbol R

Here is my code:

package com.example.mysqltest;

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

public class ReadComments extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.read_comments);
    }
}
Klemens Morbe
  • 595
  • 9
  • 24
McJim
  • 25
  • 1
  • 2
  • 7

3 Answers3

1

This error sometimes happened if there is error in one of your XML layout files. In this case, the project failed to generate the R file. Check the other errors which appears to you to know which error and in which xml layout file caused this. If the project was working before and it is not working now, check the project history to know which modification caused this error.

Mina Tadros
  • 514
  • 6
  • 18
0

I agree, the problem is elsewhere in the project, check the Problems tab (I'm using Eclipse - Juno version).

I had created the project using an earlier version of Eclipse, after importing the project into the new version of Eclipse it modified the project file from

target=Google Inc.:Google APIs:15

to

target=Google Inc.:Google APIs:10

Once I reverted back to 15 the R errors resolved themselves.

0

I had the same issue and as Mina Tadros pointed out you should look to the error log for some direction. In my case it pointed me to an EditText field that I simply deleted and rewrote and the problem was fixed.

Driver8
  • 43
  • 2
  • 7