我正在尝试在Parse Server上实例化一个子类,并执行一些query.find(),在启用"本地数据存储"之前,一切都很好。
在我将.enableLocalDataStore()添加到Parse.initialize()之后,query.find()出以下异常:
"java.lang.RuntimeException:无法创建子类的实例。"
看起来.enableLocalDataStore()正在阻塞子类的寄存器。这很奇怪,因为一件事与另一件事无关。
public class App extends Application
{
@Override
public void onCreate() {
super.onCreate();
ParseObject.registerSubclass(Place.class); // registering the subclass
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId("...")
.server("...")
.enableLocalDataStore() // if I remove this line, it works!
.build()
);
}
}
如果我删除行".enableLocalDataStore()",它工作正常。这可能是不相容吗?
这种情况也发生在其他人身上。有关此问题,请参阅GitHub页面:https://github.com/ParsePlatform/Parse-SDK-Android/issues/379
到目前为止,没有好的awnsers
我在GitHub页面上回答了,但我也会在这里回答:
如果你有
public String getObjectId() {
return getString(objectId);
}
在您的子类中,只需删除它。它没用,而且会破坏一切。