1

I completed a registration form application. It runs perfectly, however; it is now showing a build error. How can I solve this?

 @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            etusername=(EditText) findViewById(R.id.uname);
            etpassword=(EditText) findViewById(R.id.upassword);
            blogin=(Button) findViewById(R.id.blogin);
            registerlink=(Button) findViewById(R.id.register);
            blogin.setOnClickListener(this);
            registerlink.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {
            switch(v.getId()){
                case R.id.register:
                    startActivity(new Intent(this,RegisterActivity.class));
                    break;
                case R.id.blogin:

                    if(etusername.getText().toString().equals("admin") &&

                            etpassword.getText().toString().equals("admin")) {
                        startActivity(new Intent(this,HomeActivity.class));
                    }
                    else {
                        Toast.makeText(getApplicationContext(), "Invalid username/password", Toast.LENGTH_SHORT).show();
                    }

                        break;

            }
        }
    }
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Prakash Samy
  • 81
  • 1
  • 3
  • 15

6 Answers6

2

Typically you can fix this error by cleaning your project, and then rebuilding it.

Build -> Clean Project Build -> Rebuild Project

mattfred
  • 2,689
  • 1
  • 22
  • 38
1

In Android Studio go to Build -> Clean Project Build -> Rebuild Project, if that doesn't work check your xml files for errors, sometimes they don't show up, but can cause this type of error.

hopeman
  • 2,778
  • 3
  • 18
  • 33
1

there should be issue in your xml file . check your xml file in layout ,drawable folder and then clean your project.

KDeogharkar
  • 10,939
  • 7
  • 51
  • 95
0

Either your compiled for some other reasons so that R never got generated by Android Studio or you might be missing an import statement for it if you are in a different package.

Try a clean rebuild of the project and check if you need to import R.

Martin C.
  • 12,140
  • 7
  • 40
  • 52
0

1.check your XML files all Drawable images are there with the same name

2.check all imports in every activity and re-imports them

3.clear and rebuild

it may work if all are right

Sunil Chaudhary
  • 1,221
  • 12
  • 25
0

I was also facing this issue when I changed my build variant in android studio. There are two png icon files missing in current build variant which are there in previuos build, added these two files to the current build and Rebuild project solved my problem. Hope this helps

jyo cool
  • 11
  • 1