java的,R不能解析到一个变量 [英] java: R cannot be resolved to a variable
问题描述
我知道这个问题已经被问过,但我在我威茨结束与此有关。我刚刚创建了一个新的项目,收到此错误。
I know this question has been asked before but I am at my witts end with this. I have just created a new project and getting this error.
Ofcourse未被生成R.java文件
Ofcourse the R.java file is not being generated.
我使用JRE7安卓4.2.2
I am using JRE7 android 4.2.2
package com.example.myfirstapp;
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;
}
}
我们可以看到在mainactivity类没有R导入
As we can see no R import in the mainactivity class
让我们一起来看看触及清单文件:
Lets take a look at the untouched manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.myfirstapp.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>
什么都没有,看起来格格不入。我曾尝试多次关闭项目打开的项目。干净的构建。
nothing there that looks out of place. I have tried multiple close project open project. clean and builds.
没有一个资源的都是大写的,我已经尝试用项目属性Java构建路径顺序和出口。在libaries我有3个不同的Android libaries:
None of the res are in uppercase and I have experimented with the project properties java build path order and export. Under libaries I have 3 different android libaries:
安卓4.2.2 Android的私人Libaries Android的依赖
android 4.2.2 android Private Libaries android dependencies
这是使我开始渴望C ++:)
THis is making me start to long for C++ :)
推荐答案
这只是为我工作。
添加一个字符清单并保存。删除上述字符清洁投影和根下创建与buildconfig和R java中它包。
Added a character to the manifest and saved. Deleted said character cleaned projected and package created under gen with buildconfig and R java in it.
为什么工作,我不知道。
Why is worked I have no idea.
这篇关于java的,R不能解析到一个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!