I have tried finding the answer to this question on here before, but none of the fixes have worked for me. Basically, my Android project is refusing to run - even though I haven't edited it at all from the default program that is given when you make a new project.
I have a red line under R
on Eclipse, throwing up the error "R cannot be resolved to a variable". It suggests that I import android.R
, but when I do this, another red line comes up, this time under activity_main
, saying it "cannot be resolved or is not a field".
I have absolutely no idea what is going on here, and am not prolific in coding or programming at all, so any answers in absolute layman's terms would be really great. My code so far is below:
package com.randomproject.thebasics;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}