你必须在实例化它之前注册这个 ParseObject 子类 [英] You must register this ParseObject subclass before instantiating it

查看:25
本文介绍了你必须在实例化它之前注册这个 ParseObject 子类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 ParseAndroid 应用程序中遇到以下错误:

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

你必须在实例化之前注册这个 ParseObject 子类.

在我的 Application 对象中,我在 onCreate 中执行以下操作:

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.

这是我的清单文件:

 <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)

推荐答案

您必须致电ParseObject.registerSubclass(YourClassName.class);打电话之前Parse.initialize().

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
{
}

最后,您的自定义类需要一个默认的无参数构造函数,以便由 ParseObject 注册.

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

参考:子类解析对象

这篇关于你必须在实例化它之前注册这个 ParseObject 子类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆