我一直在尋找這堆棧溢出過去兩個小時,並嘗試了很多東西,但沒有奏效。R無法解析到新安裝的eclipse上的變量
我今天早上安裝了eclipse juno,並且在創建的任何項目中出現此錯誤R cannot be resolved to a variable
。另外,即使在生成項目後,我也無法在gen文件夾下看到任何文件。我已經嘗試了乾淨的項目,爲我的64位系統安裝了ia32 libs
,運行ubuntu,嘗試更改文件夾位置,重新啓動系統,但沒有任何工作。
生成的代碼是:
package tanvi.alarm;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
的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" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
/>
</RelativeLayout>
清單:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tanvi.alarm"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
http://stackoverflow.com/a/10486659/1289716 – MAC
其他人面臨的類似問題。此線程可能也有幫助[R無法解析 - Android錯誤](http://stackoverflow.com/questions/885009/r-cannot-be-resolved-android-error) – Chandra
我已經閱讀這些線程..嘗試了很多事情..did不工作..任何進一步的幫助將不勝感激 – tanvi