Search code examples
javaandroideclipser.java-file

R cannot be resolved to a variable ---


I know this question had been asked many times, and I tried everything to make it go away, but the error is still here.. I tried all these: "R cannot be resolved to a variable"? but the error won't disappear. Maybe it has something to do with the appcompat_v7 I deleted? I don't know exactly what files I should post to solve this problem.

activity_main.xml:

<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:layout_marginTop="26dp"
    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="com.example.testjk.MainActivity" >

    <TableLayout
        android:id="@+id/PlayArea"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="10dp" >




            <Button
                android:id="@+id/eleven"
                android:layout_width="120dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="50dp"
                android:text="@string/eleven" />
     //some more here

    </TableLayout>

</RelativeLayout>

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">testjk</string>
    <string name="hello_world">Hello world!</string>
    <string name="turn_human">Jouw beurt.</string>


    //some more here
</resources>

MainActivity.java

package com.example.testjk;


import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import com.example.testjk.R;

TicTacToeGame.java = in same folder as MainActivity = com.example.

package com.example.testjk;

import java.util.Random;

Solution

  • this error occurs when some xml file under /res folder have some issues or you have some errors in your manifest file. see error log on eclipse to find the real problem.