user1805
user1805

Reputation: 187

"R cannot be resolved to a variable " even after new Eclipse install

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>

Upvotes: 2

Views: 801

Answers (2)

Kalder
Kalder

Reputation: 1

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/..."

Upvotes: 0

BadSkillz
BadSkillz

Reputation: 2003

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

Upvotes: 1

Related Questions