2

I have the famous error message “R cannot be resolved to a variable” since the last 3 days and I’m totally stuck. I did follow the instructions in the following links but I can’t remove this error: Developing for Android in Eclipse: R.java not regenerating

I have crated plenty of new projects with just a new title but the same.

I even today uninstall completely Eclipse , jdk, jre and reinstall all but the same…

**Config: Windows 7 64 bits

eclipse-standard-kepler-SR1-win32-x86_64

jdk-7u51-windows-x64

jre-7u51-windows-x64

Android sdk downloaded**

I have noticed there is no file in the folder “gen” is always empty..

Thank you for your help ![enter image description here][1] ![enter image description here][2] ![enter image description here][3] ![enter image description here][4]

Mainactivity.java:

package com.example.test1;

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.main, menu);
    return true;
}

}


activity_maim 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: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>

manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test1"
android:versionCode="1"
android:versionName="1.0" >

 <uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="18" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.test1.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>
9
  • clean the application i.e go to project -> clean then select your project and clean it.. Commented Feb 9, 2014 at 16:27
  • This usually happens when you have made a mistake in your xml files. Can you try adding the code of your MainActivity? Commented Feb 9, 2014 at 16:29
  • already done plenty of times and it doesnt change anything Commented Feb 9, 2014 at 16:30
  • ?Also can you please copy your code instead of screenshots? Commented Feb 9, 2014 at 16:32
  • How can I made a mistake with xml file when I only click on "create new android project" with just the title added?Mainactivity file screenshot is added.Thank you Commented Feb 9, 2014 at 16:33

2 Answers 2

1

This looks like a 64bit issue, as android is looking for a 32bit ADT, there are a few options to solve this. Have a look at this question: Android SDK Setup under Windows 7 Pro 64 bit

I solved this under linux by doing sudo apt-get install ia32-libs

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for the link but it looks like it's more related for issue during installation.I could install the jre and sdk without problems.
I know, I had this problem on ubuntu, tried all the regular fixes and nothing worked until I found this: stackoverflow.com/a/11963196/480536. So there could still be a 32bit issue. Maybe try 32bit java?
actually, that was the only solution but I prefered initially to avoid unistall all and reinstall in 32 bits but it works now with 32 bits.Thank you
0

Have you checked your manifest.xml for mistakes? I once had a small error in my manifest that didn't show up as an error and it wouldn't generate a new R file.

I noticed another small thing that might be the issue, in your main_activity.xml you use dimension strings for padding, when creating a new project these strings are located in res/values/dimens.xml but in your layout file you are referring to @dimen instead of @dimens (notice the missing 's'). Try changing it to "@dimens/..."

1 Comment

I did change from dimen to dimens but the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.