简体   繁体   English

R.Java在我的项目中缺失,不会再生

[英]R.Java is missing from my project and will not regenerate

I've began making a new project and just as I was linking my buttons to the java I noticed my R would not resolve and come to find out that my R.java file is not there. 我已经开始创建一个新项目了,正当我将我的按钮链接到java时,我注意到我的R无法解析并且发现我的R.java文件不存在。 I've looked at other questions like this and they say to clean the project which I have done and it still does not work. 我已经看过这样的其他问题了,他们说要清理我已完成的项目,但仍然无效。 Here is my code from the pages where it wont resolve. 这是我不会解决的页面中的代码。 Thanks! 谢谢!

Invoice Java 发票Java

package com.invoice;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class InvoiceActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        Thread logoTimer = new Thread(){
            public void run(){
                try{
                    sleep(5000);
                    Intent menuIntent = new Intent("com.invoice.MENU");
                    startActivity(menuIntent);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                finally{
                    finish();
                }
            }
        };
        logoTimer.start();
    }
}

Job.java Job.java

package com.invoice;


import android.app.Activity;
import android.os.Bundle;

public class Job extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.job);
    }
}

menu.java menu.java

package com.invoice;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class menu extends Activity{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button job = (Button) findViewById(R.id.button4);
        job.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                startActivity(new Intent("com.invoice.job"));

            }
        });
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
    }
}

You probably have an error in an xml file. 您可能在xml文件中有错误。 R.java will not be generated if there are xml errors. 如果存在xml错误,则不会生成R.java。 Look through you Manifest.xml and all your layout, values, and any other xml files in res. 查看Manifest.xml以及res中的所有布局,值和任何其他xml文件。

Once you have found and fixed the error, clean the project. 找到并修复错误后,清理项目。

You probably have problem in resource folder, first solve that error.numeric name of image can generate errors.After solving the errors just clean your project or Build your Project. 您可能在资源文件夹中遇到问题,首先解决该错误。图像的数字名称可能会产生错误。解决错误后,只需清理项目或构建项目。 R.java build again if error is fixed. 如果错误得到修复,则再次构建R.java。

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

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