Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Adding Users Using Parse.com Logging Out

Self Destructing Message error

        mLoginButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                String username = mUsername.getText().toString();
                String password = mPassword.getText().toString();

                username = username.trim();
                password = password.trim();

                if(username.isEmpty() || password.isEmpty()){
                    AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
                    builder.setMessage(R.string.login_error_message)
                    .setTitle(R.string.login_error_title)
                    .setPositiveButton(android.R.string.ok, null);
                    AlertDialog dialog = builder.create();
                    dialog.show();

                }
                else{
                    //login
                    ParseUser.logInInBackground(username, password, new LogInCallback() {

                        @Override
                        public void done(ParseUser user, ParseException e) {
                            if (e == null){
                                //Success!
                                Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                                startActivity(intent);
                            }
                            else{
                                AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
                                builder.setMessage(e.getMessage())
                                .setTitle(R.string.login_error_title)
                                .setPositiveButton(android.R.string.ok, null);
                                AlertDialog dialog = builder.create();
                                dialog.show();
                            }
                        }
                    });
                }
            }
        });

Is there something wrong with this code? When I try to run my app it says "Unfortunately, Ribbit has stopped" My LogCat tells me that there is an error on this line "mLoginButton.setOnClickListener(new View.OnClickListener() {" which Includes all of this. I can't seem to find one and I don't know what to do.

6 Answers

Did you make sure that the following line (or something similar) exists? mLoginButton = (Button)findViewById(R.id.loginButton); If you didn't, that's why an exception was thrown in your app. Check, try again and if you're still failing to run let me know.

Thank you for drawing my attention to that. The problem was that I put down R.id.signupbutton instead of loginbutton.

Now my app will actually start up with out getting that error, but each time I try to click on the login button it still says " Unfortunately, Ribbit has stopped"

Glad to hear that you've fixed part the problem. What emulator are you using to run the Ribbit App? Why don't you try an emulator with an Android version between 4.0 and 4.6?

I'm using my Galaxy s4. I just connect it to the computer and run my apps that way because the emulators are too much for my computer. I have Android 4.3 so I really have no Idea what the problem might be.

Nick Tosto
Nick Tosto
8,574 Points

I'm having the exact same problem. Every time I click Login I get a null pointer exception error. My code for the LoginActivity seems to be exactly the same as the code I downloaded from Treehouse so I'm stumped. I'm running the app on my HTC One with android 4.3

Okay, I for me the problem was that I identified my username and password field with the id from the sign up screen instead of from the log in screen. check that that might be the problem.

Nick Tosto
Nick Tosto
8,574 Points

Ahh yes! That was my problem. Thanks a million!

Thomas Fallaize
Thomas Fallaize
3,493 Points

Thank you Simeon, this helped me loads!

You're welcome :)

Eric De Wildt
PLUS
Eric De Wildt
Courses Plus Student 13,077 Points

I ran into this problem as well and had to make sure all my ids were VERY clearly identified with their views. I feel a little ashamed at the mistake but I am soo happy that i solved the problem. I didn't do it alone though, I had the Treehouse forum and community to help,so in effect WE solved the problem!