gpt4 book ai didi

java - "R cannot be resolved to a variable "即使在安装新的 Eclipse 之后

转载 作者:行者123 更新时间:2023-11-30 11:22:29 26 4
gpt4 key购买 nike

自从过去 3 天以来,我一直收到著名的错误消息“R 无法解析为变量”,我完全被困住了。我确实按照以下链接中的说明进行操作,但无法消除此错误: Developing for Android in Eclipse: R.java not regenerating

我已经创建了很多新项目,只是使用了一个新标题,但都是一样的。

我什至在今天完全卸载了 Eclipse、jdk、jre 并重新安装,但几乎一样……

**配置:Windows 7 64位

eclipse-标准-开普勒-SR1-win32-x86_64

jdk-7u51-windows-x64

jre-7u51-windows-x64

Android SDK 下载**

我注意到“gen”文件夹中没有文件总是空的..

谢谢你的帮助![在此处输入图片描述][1]![在此处输入图片描述][2]![在此处输入图片描述][3]![在此处输入图片描述][4]

主 Activity .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>

list .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>

最佳答案

这看起来像一个 64 位问题,因为 android 正在寻找 32 位 ADT,有几个选项可以解决这个问题。看看这个问题:Android SDK Setup under Windows 7 Pro 64 bit

我在 linux 下通过 sudo apt-get install ia32-libs

解决了这个问题

关于java - "R cannot be resolved to a variable "即使在安装新的 Eclipse 之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21661609/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com