Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
Android Studio Keep getting error on launch

For some reason my app is keep coming up with this error. I have added the error log below but cannot work out what the problem is. I have tried many times to figure it out but still not getting anywhere. Hopefully you can understand the error log.

    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at .....buildaempiredesign.GameRegister.onCreate(GameRegister.java:34)

The code for that is the bRegister.setOnClickListener section of code below.

            bRegister.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                final String email = etEmail.getText().toString();
                final String password = etPassword.getText().toString();
                @SuppressLint("SimpleDateFormat") final String birthday = new SimpleDateFormat("dd/MM/yyyy").format(etBirthday.getText().toString());
                final String playername = etPersonName.getText().toString();
                final String gender = etPersonName.getText().toString();
                final String gamename = etGameName.getText().toString();

                Response.Listener<String> responceListener = new Response.Listener<String>(){
                    @Override
                    public void onResponse(String response) {
                        try {
                            JSONObject jsonResponce = new JSONObject(response);
                            boolean error = jsonResponce.getBoolean("error");

                            if (!error){
                                Intent intent = new Intent(GameRegister.this, GameLogin.class);
                                GameRegister.this.startActivity(intent);
                            } else {
                                AlertDialog.Builder builder = new AlertDialog.Builder(GameRegister.this);
                                builder.setMessage("Login Failed")
                                        .setNegativeButton("Retry", null)
                                        .create()
                                        .show();
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                };

                RegisterRequest registerRequest = new RegisterRequest(email, password, playername, gender, birthday, gamename, responceListener);
                queue.add(registerRequest);
            }
        });
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

where is your Code at line 34? makesure you have initialized your Button. and your button id is not wrong.

Button bRegister;

or Button bRegister = (Button)findViewById(R.id.yourbuttonid);

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!