[英]ParseException: “You must register this ParseObject subclass before instantiating it.”
[英]You must register this ParseObject subclass before instantiating it
我在使用Parse
Android
应用程序中收到以下错误:
You must register this ParseObject subclass before instantiating it.
在我的Application
对象中,我在onCreate
执行以下操作:
Parse.enableLocalDatastore(this);
Parse.initialize(this, "code", "code");
那么为什么我仍然会收到此错误? 它昨天工作正常,但它突然停止工作。
这是我的清单文件:
<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()
之前。
此外,您需要注释您的自定义类,如下所示:
@ParseClassName("YourClassName")
public class YourClassName extends ParseObject
{
}
最后,您的自定义类需要一个默认的无参数构造函数才能由ParseObject
注册。
参考: 子类化解析对象
你还必须把它放在你的Manifest中:
<application
android:name="ParseApplication"
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
YOUR ACTIVITY 1
/>
<activity
YOUR ACTIVITY 2
/>
</application>
然后尝试交换以下这些行
Parse.enableLocalDatastore(this);
Parse.initialize(this, "key", "key");
像这样:
Parse.initialize(this, "key", "key");
Parse.enableLocalDatastore(this);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.