我刚创建了一个新活动(project-> new-> android活动),我得到一个错误,其中R文件无法识别活动创建的布局。我使用 Ubuntu 13.10(64位)
public class OrderKaraokeActivity extends SherlockActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_order_karaoke);
}
}
activity_order_karaoke:
<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=".OrderKaraokeActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
控制台: 描述资源路径位置类型 activity_order_karaoke无法解析或者不是字段OrderKaraokeActivity.java / src / com / example / adicionalesprueba第18行Java问题
导入:
控制台问题:
答案 0 :(得分:7)
删除以下
import com.twable.R;
import com.twable.R.layout;
import com.twable.R.menu;
并加入import com.example.adicionalesprueba.R
<强> ---- 强>
检查您的包浏览器(eclipse的左侧窗格),打开项目的gen
文件夹,打开项目包,您应该看到R.java
文件。如果不这样做,则表示您没有生成R文件。尝试清理项目Project --> Clean
。如果文件仍然不存在,那么您的R
文件尚未构建。这可能由于许多原因而发生。一个非常常见的问题是您的某个XML文件没有正确构建
答案 1 :(得分:1)
检查您的进口商品。如果它在那里生成,请删除导入android.R 。