0

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. only error i am getting is for R.java file, which is "R cannot be resolved to a variable". i have already tried importing R into my project using Import.android.R, but error is still there. 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);
Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
  • R.java is missing http://stackoverflow.com/questions/4085959/no-generated-r-java-file-in-my-project?rq=1 – wxl24life Aug 24 '13 at 14:11

3 Answers3

1

Normally it happens when your res folder contains some files with non-acceptable names (e.g file names in drawable folders cannot have '-' character or space between words) or when some error occurs in xml parsing. And its not android.R that you should import, you have to import com.example.whereareyou3.R

0

Providing that your activity has the same package as where your layouts are stored it should work. Importing R will not fix it.

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.

LondonAppDev
  • 8,501
  • 8
  • 60
  • 87
0

R .java missing may occur due to.error.in.some.xml file

if that is.not there check by cleaning your code .

cafebabe1991
  • 4,928
  • 2
  • 34
  • 42