0

I lost R.java class when I clean my project. So please how can I get it back? Cause R.java define automatically in gen. Is there any way to do that?

I have imported a package to my project and I use it in project classes and pages but when I navigate to a page use a package the app gives a waiting and it still waiting.

How can I stop this problem and go to the next page?

public class HomePage extends Activity {    
    @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.person);
            Carousel car=(Carousel) findViewById(R.id.carousel);

            car.setOnItemClickListener(new OnItemClickListener(){

                public void onItemClick(CarouselAdapter<?> parent, View view,
                        int position, long id) {
                    // TODO Auto-generated method stub
                    if(position==0){
                        Intent i=new Intent(HomePage.this,StudentInformationActivity.class);

                        startActivity(i);
                        }else if(position==1){
                            Intent i=new Intent(HomePage.this,PersonalProfileActivity.class);
                            startActivity(i);
                        }

                }

            });
        }


    }

on this page that we used person as activities but it doesn't work.

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
Meral AB
  • 5
  • 1
  • 5
  • 1
    There must be some error in the project that´s why android cannot generate R.java. if you find and fix that error. It will be able to create R.java. These types of errors are usually related with Layouts, Res folder or Imported packages. – Dusean Singh Aug 29 '12 at 08:52
  • About the activity not working, have you tried adding the activity to the manifest? – Warpzit Aug 29 '12 at 08:53
  • 2
    Make sure there are no errors in layout files. I had similar problem and was because of error in layout files. – prayagupa Aug 29 '12 at 08:55
  • @DuseanSingh if i define it by me it will define the strings Ids and .... automatically ?? or should i define every thing? – Meral AB Aug 29 '12 at 11:48
  • @PrayagUpd it was work great before cleaning the project I ave more than 30 xml file:(( – Meral AB Aug 29 '12 at 11:49
  • @MeralAB AB I don't think there is other method than looking into each .xml file to find out the error in .xml file. – prayagupa Aug 29 '12 at 12:16

3 Answers3

0

Sometimes when you clean your project the R file disappears, I had the same issue.

The way I fixed it was:

  • Make sure all the import android.R was removed -Clean again (if this doesn't fix it, restart eclipse and try again)

Or

  • Put the pointers to R file in comment f.e. // setContentView(R.layout.main);
  • If all the pointers to R file are in comment, you should get only warnings in the file, and hopefully errors somewhere else.
  • Fix the errors and then uncomment the pointers. Sometimes eclipse ignores some errors and drops the R file and then says nothing about it, which is annoying, but this will fix it. :)

  • If this still doesn't work, you can try create a new project and copy paste your code in it.

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
Sathish
  • 4,403
  • 7
  • 31
  • 53
  • I have more than 30 class all are have same error I did as u told me to do for 1 of them but nothing appear in it's xml file :( – Meral AB Aug 29 '12 at 11:54
  • http://stackoverflow.com/questions/4085959/no-generated-r-java-file-in-my-project try this link – Sathish Aug 29 '12 at 11:56
  • There might be 2 possibilities: 1. There might be any error in one of XML files. 2. Just clean and build your project again. – Sathish Aug 29 '12 at 11:58
  • aha thanx alot:) actually I back to the old copy of the project and made my updates again so now every thing is good but i didnt found a way to get the class – Meral AB Aug 30 '12 at 07:03
0

Just Save the XML Layout file and It will automatically generate the new R file. But make sure at first that the file does not contain any errors.

About the second Question, I'm not sure that I got it will. I think you mean you can not refer to the PersonalProfileActivity.class in this activity. Make sure that you imported the package contains this class if it is in another package. Also do not forget to add it to your manifest file.

MSaudi
  • 4,442
  • 2
  • 40
  • 65
  • actually both class at the same package and added to to manifest so I'm so confused about this cause i did every thing correctly :| and about R I the app was work great but today when I clean it i lost it I tryed what you said but nothing change:( thanx anway – Meral AB Aug 29 '12 at 11:43
0

Could be errors in your xml files. Correct the errors and clean the project. It will come back!

Lazy Ninja
  • 22,342
  • 9
  • 83
  • 103