0

I'm running into a problem with compiling the beginning of the program, This is the following code.

The error I'm getting is

"R cannot be resolved as a variable" line 12

"R cannot be resolved as a variable" line 18

package com.example.hangman_game_android;

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);    //line 12
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);    //line 18
        return true;
    }

}

The other part of my Code is ...

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />
        
</RelativeLayout>
Community
  • 1
  • 1
Cris
  • 128
  • 3
  • 4
  • 17
  • 2
    Post the error you are getting...it's very helpful. Also, try cleaning your project. Most likely, has something to do [with this](http://stackoverflow.com/questions/2757107/developing-for-android-in-eclipse-r-java-not-generating) – codeMagic Feb 20 '14 at 00:48
  • I just added some comments to clear my mistake sorry. – Cris Feb 20 '14 at 00:55
  • 1
    I see that. See the link I posted in my first comment – codeMagic Feb 20 '14 at 00:56
  • Thanks for the response I didn't notice it was similar problem encounter by many. – Cris Feb 20 '14 at 01:40

1 Answers1

0

As codeMagic suggested, I would perform a cleaning of the project and that would resolve the missing references.

  • Welcome to SO! I realize you can't comment but this isn't an answer. And since it's already been asked to describe the problem, it's probably not necessary – codeMagic Feb 20 '14 at 00:55