简体   繁体   English

每次都会自动删除R.java文件

[英]R.java file getting deleted automatically every time

i am creating a simple splash screen , but i am unable to understand that why R.java file is getting deleted automatically every time i create a new project. 我正在创建一个简单的启动画面,但我无法理解为什么每次创建新项目时都会自动删除R.java文件。 only error i am getting is for R.java file, which is "R cannot be resolved to a variable". 我得到的唯一错误是R.java文件,即“R无法解析为变量”。 i have already tried importing R into my project using Import.android.R, but error is still there. 我已经尝试使用Import.android.R将R导入我的项目,但错误仍然存​​在。 please anybody with solution. 请任何有解决方案的人。 thanks 谢谢

the part of the code in which error is as follows: 错误如下的代码部分:

package com.example.whereareyou3;

//import android.R;
import android.R;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ProgressBar;

public class MainActivity extends Activity {

    Handler h1 = new Handler();
    private ProgressBar mProgress;
    long ms,splashTime=7000;
    boolean splashActive = true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main);

Normally it happens when your res folder contains some files with non-acceptable names (eg file names in drawable folders cannot have '-' character or space between words) or when some error occurs in xml parsing. 通常,当您的res文件夹包含一些具有不可接受名称的文件时(例如,可绘制文件夹中的文件名不能包含' - '字符或单词之间的空格)或者在xml解析中发生某些错误时,就会发生这种情况。 And its not android.R that you should import, you have to import com.example.whereareyou3.R 并且它不是你应该导入的android.R,你必须导入com.example.whereareyou3.R

Providing that your activity has the same package as where your layouts are stored it should work. 如果您的活动具有与存储布局相同的包,则应该可以使用。 Importing R will not fix it. 导入R不会修复它。

You can most likely resolve this by cleaning the project. 您最有可能通过清理项目来解决此问题。 Go to Project > Clean. 转到项目>清洁。

Also I have not seen this error since upgrading to the latest version of Eclipse and ADT. 此外,自升级到最新版本的Eclipse和ADT以来,我没有看到此错误。

R .java missing may occur due to.error.in.some.xml file 由于.error.in.some.xml文件,可能会丢失R .java

if that is.not there check by cleaning your code . 如果那样。不是通过清理你的代码检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM