Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse crash on creating user

I am using Parse as my backend for my Android app. I have a crash report for only some android devices when I try to create a User object. The error on the crash is:

Caused by: java.lang.IllegalArgumentException: 
You must register this ParseObject subclass before instantiating it.
at com.parse.ParseObject.<init>(ParseObject.java:184)

The devices that submitted the crash report are:

HTC Desire 510 (htc_a11ul)  2   33.3% Android 4.4
Xperia E3 (D2203)   1   16.7%  Android 4.4
Galaxy S4 (jflte)   1   16.7%  Android 4.4
Galaxy S5 (klte)    1   16.7%  Android 4.4

This is extremely odd as I currently have tested my code on the Samsung Note 4, Galaxy S4, S5, and Nexus 5 without any issues. I am not sure why Parse is asking me to subclass out of nowhere as I am not trying to use the subclass functionality offered by Parse. Again, I've tested this code on other devices without any issues.

Can someone please tell me how to fix this? I have included the code below where I create the User and it crashes.

Thank you!

    Parse.initialize(this, "XXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXX");
    ParseUser user = new ParseUser();
    user.setUsername(email);
    user.setPassword(confirmPassword);
    user.setEmail(email);
    user.put("deviceID", deviceID);
    user.put("name", fullName);

    progress = new ProgressDialog(Register.this);
    progress.setMessage("Creating Account... Please Wait");
    progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progress.setIndeterminate(true);
    progress.setCanceledOnTouchOutside(false);
    progress.setCancelable(false);
    progress.show();


    user.signUpInBackground(new SignUpCallback() {
        public void done(ParseException e) {
            if (e == null) {
                // Hooray! Let them use the app now.
                Intent i = new Intent(Register.this, DeviceSettingsIntro.class);
                startActivity(i);
                progress.hide();
                btnRegister.setEnabled(true);
            } else {
                // Sign up didn't succeed. Look at the ParseException
                // to figure out what went wrong
                progress.hide();
                checkParseError(e);
                btnRegister.setEnabled(true);
            }
        }
    });
like image 601
Teddy13 Avatar asked Jun 16 '15 20:06

Teddy13


2 Answers

Have you tried initializing Parse using an Application class as described by Parse quick start guide? Maybe Parse wasn't initialized successfully

Create a class that extends Application, and for the content:

@Override
public void onCreate() {
    super.onCreate();

    Parse.enableLocalDatastore(this); //might not be needed
    Parse.initialize(this, "xxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxx");
}

Edit your manifest < application > tag, add this:

    android:name="com.yourpackage.applicationclass"

//so it should look like (for example) : 
<application
    android:name="com.yourpackage.yourapplicationclass"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    //put activities here

</application>

This way, Parse will always be initialized when your Application launches, regardless of Activity.

like image 137
reidzeibel Avatar answered Sep 19 '22 12:09

reidzeibel


You can try register the ParseUser class before calling Parse.initialize(), like this:

ParseObject.registerSubclass(ParseUser.class);
Parse.initialize();

I know you don't need to do this, but may be a work around for your problem. You can test and post the results!

Otherwise you can always look for more info with the parse team.

like image 44
Clayton Oliveira Avatar answered Sep 20 '22 12:09

Clayton Oliveira