我正在尝试像这样创建一个新的 ParseObject:
ParseObject message = new ParseObject("Message");
当我运行该应用程序时,出现以下错误:
java.lang.IllegalArgumentException: You must create this type of ParseObject using ParseObject.create() or the proper subclass.
这是我的完整代码
ParseObject message = new ParseObject("Message");
message.put("content", "words go here");
message.saveInBackground();
如果需要,可以发布更多代码。感谢所有帮助!
最佳答案
来自这个例子:https://parse.com/docs/android_guide#objects
您可以像这样创建对象:
ParseObject gameScore = new ParseObject("GameScore");
gameScore.put("score", 1337);
gameScore.put("playerName", "Sean Plott");
gameScore.put("cheatMode", false);
gameScore.saveInBackground();
事实上,类似的代码现在可以在我的应用程序中运行。
如果您已经创建了一个扩展 ParseObject 的 Message 模型,您可能想要调用 new Message() ,如这个问题所示:
https://www.parse.com/questions/new-parseobjectchat-crushes-the-app
这个答案表明使用 .create() 可能会解决问题,但没有解释原因。
App crash when I submit a new post to Parse
另请确保您使用正确的 key 正确初始化您的应用,并且您使用的是最新版本的 SDK。
关于android - 新的 ParseObject ("Message") 使应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29154155/