Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Self-Destructing Message Android App Adding Users Using Parse.com Creating a New User on Parse

Create a User?

Ribbit loads fine but when i try to sign up with password,email,and username it says Unfortunately Ribbit has stopped working?

6 Answers

George Pirchalaishvili
George Pirchalaishvili
3,747 Points

Well first of all you dont have any code in else block, which should create user.

Can you copy error which pops up in logcat?

package com.breyonna.ribbit;

import android.app.AlertDialog; import android.content.Intent; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.EditText;

import com.parse.ParseException; import com.parse.ParseUser; import com.parse.SignUpCallback;

public class SignUpActivity extends ActionBarActivity {

protected EditText mUsername;
protected EditText mPassword;
protected EditText mEmail;
protected Button mSignUpButton;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_up);
    mUsername = (EditText)findViewById(R.id.usernameField);
    mPassword = (EditText)findViewById(R.id.passwordField);
    mEmail = (EditText)findViewById(R.id.emailField);
    mSignUpButton = (Button)findViewById(R.id.signupButton);
    mSignUpButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String username = mUsername.getText().toString();
            String password = mPassword.getText().toString();
            String email = mEmail.getText().toString();

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

            if (username.isEmpty() || password.isEmpty() || email.isEmpty()) {
                AlertDialog.Builder builder = new AlertDialog.Builder(SignUpActivity.this);
                builder.setMessage(R.string.signup_error_message)
                        .setTitle(R.string.signup_error_title)
                        .setPositiveButton(android.R.string.ok, null);
                AlertDialog dialog = builder.create();
                dialog.show();
            }
            else {
                // create the new user!
                ParseUser newUser = new ParseUser();
                newUser.setUsername(username);
                newUser.setPassword(password);
                newUser.setEmail(email);
                newUser.signUpInBackground(new SignUpCallback() {
                    @Override
                    public void done(ParseException e) {
                        if (e == null) {
                            // Success!
                            Intent intent = new Intent(SignUpActivity.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(SignUpActivity.this);
                            builder.setMessage(e.getMessage())
                                    .setTitle(R.string.signup_error_title)
                                    .setPositiveButton(android.R.string.ok, null);
                            AlertDialog dialog = builder.create();
                            dialog.show();
                        }
                    }
                });
            }
        }
    });
}
 @Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_sign_up, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}

03-27 22:42:03.969 1912-1912/com.breyonna.ribbit I/art﹕ Not late-enabling -Xcheck:jni (already on) 03-27 22:42:04.084 1912-1927/com.breyonna.ribbit D/OpenGLRenderer﹕ Render dirty regions requested: true 03-27 22:42:04.087 1912-1912/com.breyonna.ribbit D/﹕ HostConnection::get() New Host Connection established 0xae0d2d70, tid 1912 03-27 22:42:04.153 1912-1912/com.breyonna.ribbit D/Atlas﹕ Validating map... 03-27 22:42:04.305 1912-1927/com.breyonna.ribbit D/﹕ HostConnection::get() New Host Connection established 0xa6c43040, tid 1927 03-27 22:42:04.402 1912-1927/com.breyonna.ribbit I/OpenGLRenderer﹕ Initialized EGL, version 1.4 03-27 22:42:04.536 1912-1927/com.breyonna.ribbit D/OpenGLRenderer﹕ Enabling debug mode 0 03-27 22:42:04.551 1912-1927/com.breyonna.ribbit W/EGL_emulation﹕ eglSurfaceAttrib not implemented 03-27 22:42:04.551 1912-1927/com.breyonna.ribbit W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa6c2c820, error=EGL_SUCCESS 03-27 22:42:08.450 1912-1912/com.breyonna.ribbit I/Choreographer﹕ Skipped 39 frames! The application may be doing too much work on its main thread. 03-27 22:42:09.210 1912-1912/com.breyonna.ribbit I/Choreographer﹕ Skipped 45 frames! The application may be doing too much work on its main thread. 03-27 15:42:10.401 1912-1927/com.breyonna.ribbit W/EGL_emulation﹕ eglSurfaceAttrib not implemented 03-27 15:42:10.401 1912-1927/com.breyonna.ribbit W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa6c2c820, error=EGL_SUCCESS 03-27 15:44:54.971 1912-1927/com.breyonna.ribbit W/EGL_emulation﹕ eglSurfaceAttrib not implemented 03-27 15:44:54.971 1912-1927/com.breyonna.ribbit W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xae0d9b60, error=EGL_SUCCESS 03-27 15:56:08.314 2334-2349/com.breyonna.ribbit D/OpenGLRenderer﹕ Render dirty regions requested: true 03-27 15:56:08.372 2334-2334/com.breyonna.ribbit D/﹕ HostConnection::get() New Host Connection established 0xa660bd80, tid 2334 03-27 15:56:08.521 2334-2334/com.breyonna.ribbit D/Atlas﹕ Validating map... 03-27 15:56:08.628 2334-2349/com.breyonna.ribbit D/﹕ HostConnection::get() New Host Connection established 0xa662d0f0, tid 2349 03-27 15:56:08.722 2334-2349/com.breyonna.ribbit I/OpenGLRenderer﹕ Initialized EGL, version 1.4 03-27 15:56:08.760 2334-2349/com.breyonna.ribbit D/OpenGLRenderer﹕ Enabling debug mode 0 03-27 15:56:08.786 2334-2349/com.breyonna.ribbit W/EGL_emulation﹕ eglSurfaceAttrib not implemented 03-27 15:56:08.786 2334-2349/com.breyonna.ribbit W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa661be60, error=EGL_SUCCESS 03-27 15:57:33.169 2334-2346/com.breyonna.ribbit I/art﹕ Background sticky concurrent mark sweep GC freed 4376(280KB) AllocSpace objects, 0(0B) LOS objects, 30% free, 790KB/1135KB, paused 5.086ms total 25.545ms 03-27 15:57:33.346 2334-2349/com.breyonna.ribbit W/EGL_emulation﹕ eglSurfaceAttrib not implemented 03-27 15:57:33.346 2334-2349/com.breyonna.ribbit W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa5797c20, error=EGL_SUCCESS 03-27 15:57:38.157 2334-2334/com.breyonna.ribbit I/Choreographer﹕ Skipped 297 frames! The application may be doing too much work on its main thread. 03-27 15:58:26.499 2334-2334/com.breyonna.ribbit D/AndroidRuntime﹕ Shutting down VM --------- beginning of crash 03-27 15:58:26.500 2334-2334/com.breyonna.ribbit E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.breyonna.ribbit, PID: 2334 java.lang.IllegalArgumentException: You must register this ParseObject subclass before instantiating it. at com.parse.ParseObject.<init>(ParseObject.java:166) at com.parse.ParseObject.<init>(ParseObject.java:127) at com.parse.ParseUser.<init>(ParseUser.java:89) at com.breyonna.ribbit.SignUpActivity$1.onClick(SignUpActivity.java:55) at android.view.View.performClick(View.java:4756) at android.view.View$PerformClick.run(View.java:19749) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 03-27 15:58:40.352 2334-2334/com.breyonna.ribbit I/Process﹕ Sending signal. PID: 2334 SIG: 9 03-27 15:58:40.601 2366-2381/com.breyonna.ribbit D/OpenGLRenderer﹕ Render dirty regions requested: true 03-27 15:58:40.635 2366-2366/com.breyonna.ribbit D/﹕ HostConnection::get() New Host Connection established 0xae0bae10, tid 2366 03-27 15:58:40.637 2366-2366/com.breyonna.ribbit D/Atlas﹕ Validating map... 03-27 15:58:40.717 2366-2381/com.breyonna.ribbit D/﹕ HostConnection::get() New Host Connection established 0xa6643040, tid 2381 03-27 15:58:40.725 2366-2381/com.breyonna.ribbit I/OpenGLRenderer﹕ Initialized EGL, version 1.4 03-27 15:58:40.760 2366-2381/com.breyonna.ribbit D/OpenGLRenderer﹕ Enabling debug mode 0 03-27 15:58:40.775 2366-2381/com.breyonna.ribbit W/EGL_emulation﹕ eglSurfaceAttrib not implemented 03-27 15:58:40.775 2366-2381/com.breyonna.ribbit W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa662d900, error=EGL_SUCCESS

sorry i didnt mean to paste the whole logcat it doesnt say error it just says Ribbit has stopped working but i think this is the info.

Shutting down VM --------- beginning of crash 03-27 15:58:26.500 2334-2334/com.breyonna.ribbit E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.breyonna.ribbit, PID: 2334 java.lang.IllegalArgumentException: You must register this ParseObject subclass before instantiating it. at com.parse.ParseObject.<init>(ParseObject.java:166) at com.parse.ParseObject.<init>(ParseObject.java:127) at com.parse.ParseUser.<init>(ParseUser.java:89) at com.breyonna.ribbit.SignUpActivity$1.onClick(SignUpActivity.java:55) at android.view.View.performClick(View.java:4756) at android.view.View$PerformClick.run(View.java:19749) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 03-27 15:58:40.352 2334-2334/com.breyonna.ribbit I/Process﹕ Sending signal. PID: 2334 SIG: 9 03-27 15:58:40.601 2366-2381/com.breyonna.ribbit D/OpenGLRenderer﹕ Render dirty regions requested: true 03-27 15:58:40.635 2366-2366/com.breyonna.ribbit D/﹕ HostConnection::get() New Host Connection established 0xae0bae10, tid 2366 03-27 15:58:40.637 2366-2366/com.breyonna.ribbit D/Atlas﹕ Validating map... 03-27 15:58:40.717 2366-2381/com.breyonna.ribbit D/﹕ HostConnection::get() New Host Connection established 0xa6643040, tid 2381 03-27 15:58:40.725 2366-2381/com.breyonna.ribbit I/OpenGLRenderer﹕ Initialized EGL, version 1.4 03-27 15:58:40.760 2366-2381/com.breyonna.ribbit D/OpenGLRenderer﹕ Enabling debug mode 0 03-27 15:58:40.775 2366-2381/com.breyonna.ribbit W/EGL_emulation﹕ eglSurfaceAttrib not implemented 03-27 15:58:40.775 2366-2381/com.breyonna.ribbit W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa662d900, error=EGL_SUCCESS

Wiyo Io
Wiyo Io
2,304 Points

hi. I had the same problem. It has been solved a bit lower in the questions for this tutorial (https://teamtreehouse.com/forum/register-parseobject-before-instantiating-it).

For me, the problem was caused because I was initializing parse in my MainActivity onCreate(). It should be done in the application instead.

So create a new class (call it RibbitApplication) and pop in the following code (changing it where relevant to your values e.g. YourApplication = RibbitApplication):

public class YourApplication extends Application { @Override public void onCreate() { super.onCreate(); Parse.initialize(this, "id","key"); } }

Now you need to declare it to the manifest as follows (changing where relevant):

<application android:name="com.you.yourapp.YourApplication"

stackoverflow link:

http://stackoverflow.com/questions/25026185/how-to-know-when-parse-initialize-has-already-been-called