Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You must register this ParseObject subclass before instantiating it

I am getting the following error in my Android application using Parse:

You must register this ParseObject subclass before instantiating it.

In my Application object, I am doing the following inside onCreate:

Parse.enableLocalDatastore(this);
Parse.initialize(this, "code", "code");

So why am I still getting this error? It was working fine yesterday but it's all of a sudden stopped working.

This is my Manifest file:

 <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        ....

LogCat:

 java.lang.IllegalArgumentException: You must register this ParseObject subclass before instantiating it.
            at com.parse.ParseObject.<init>(ParseObject.java:157)
            at com.parse.ParseObject.<init>(ParseObject.java:119)
            at usmaan.app.models.Game.<init>(Game.java:25)
            at usmaan.app.models.Game.to(Game.java:86)
            at usmaan.app.adapters.GamesAdapter.getView(GamesAdapter.java:47)
            at android.widget.AbsListView.obtainView(AbsListView.java:2344)
            at android.widget.ListView.makeAndAddView(ListView.java:1864)
like image 263
Subby Avatar asked Dec 05 '22 04:12

Subby


1 Answers

You must call ParseObject.registerSubclass(YourClassName.class); before calling Parse.initialize().

In addition, you need to annotate your custom class like this:

@ParseClassName("YourClassName")
public class YourClassName extends ParseObject
{
}

Finally, your custom class needs a default no-args constructor in order to be registered by ParseObject.


Reference: Subclassing Parse Object

like image 170
Samuel Barbosa Avatar answered Dec 10 '22 11:12

Samuel Barbosa