我在下面收到此错误,并且不知道如何处理它。我甚至不知道在这里发布什么代码,因为我似乎无法找到我的代码中导致此错误的位置。还有一件事要提到:这个错误不会发生在我的第一个测试设备上,这是一个HTC令人难以置信的运行android 4.0.4,但我的第二个测试设备是一个运行4.4.2的三星平板电脑确实收到此错误。
编辑:我认为它与我的解析安装对象有关,因为它没有保存到第二个设备的数据库中。在我的代码中,我有:
ParseInstallation UserPushObj = ParseInstallation.getCurrentInstallation();
System.out.println(UserPushObj.getObjectId());
它返回一个解析安装对象,其对象ID不在数据库中。我试着
UserPushObj.saveInBackground();
但它没有保存。有人能指出我能做些什么来解决它吗?
E/ParseCommandCache(8040): Failed to run command.
E/ParseCommandCache(8040): com.parse.ParseException: object not found for update
E/ParseCommandCache(8040): at com.parse.ParseCommand.onPostExecute(ParseCommand.java:334)
E/ParseCommandCache(8040): at com.parse.ParseRequest$5.then(ParseRequest.java:321)
E/ParseCommandCache(8040): at com.parse.ParseRequest$5.then(ParseRequest.java:318)
E/ParseCommandCache(8040): at com.parse.Task$11.run(Task.java:481)
E/ParseCommandCache(8040): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
E/ParseCommandCache(8040): at com.parse.Task.completeAfterTask(Task.java:477)
E/ParseCommandCache(8040): at com.parse.Task.continueWithTask(Task.java:353)
E/ParseCommandCache(8040): at com.parse.Task.continueWithTask(Task.java:364)
E/ParseCommandCache(8040): at com.parse.Task$9.then(Task.java:410)
E/ParseCommandCache(8040): at com.parse.Task$9.then(Task.java:402)
E/ParseCommandCache(8040): at com.parse.Task$11.run(Task.java:481)
E/ParseCommandCache(8040): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
E/ParseCommandCache(8040): at com.parse.Task.completeAfterTask(Task.java:477)
E/ParseCommandCache(8040): at com.parse.Task.access$400(Task.java:22)
E/ParseCommandCache(8040): at com.parse.Task$7.then(Task.java:346)
E/ParseCommandCache(8040): at com.parse.Task$7.then(Task.java:343)
E/ParseCommandCache(8040): at com.parse.Task.runContinuations(Task.java:510)
E/ParseCommandCache(8040): at com.parse.Task.access$800(Task.java:22)
E/ParseCommandCache(8040): at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:565)
E/ParseCommandCache(8040): at com.parse.Task$TaskCompletionSource.setResult(Task.java:599)
E/ParseCommandCache(8040): at com.parse.Task$11$1.then(Task.java:493)
E/ParseCommandCache(8040): at com.parse.Task$11$1.then(Task.java:485)
E/ParseCommandCache(8040): at com.parse.Task$10.run(Task.java:448)
E/ParseCommandCache(8040): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
E/ParseCommandCache(8040): at com.parse.Task.completeImmediately(Task.java:444)
E/ParseCommandCache(8040): at com.parse.Task.access$300(Task.java:22)
E/ParseCommandCache(8040): at com.parse.Task$6.then(Task.java:311)
E/ParseCommandCache(8040): at com.parse.Task$6.then(Task.java:308)
E/ParseCommandCache(8040): at com.parse.Task.runContinuations(Task.java:510)
E/ParseCommandCache(8040): at com.parse.Task.access$800(Task.java:22)
E/ParseCommandCache(8040): at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:565)
E/ParseCommandCache(8040): at com.parse.Task$TaskCompletionSource.setResult(Task.java:599)
E/ParseCommandCache(8040): at com.parse.Task$11$1.then(Task.java:493)
E/ParseCommandCache(8040): at com.parse.Task$11$1.then(Task.java:485)
E/ParseCommandCache(8040): at com.parse.Task$10.run(Task.java:448)
E/ParseCommandCache(8040): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
E/ParseCommandCache(8040): at com.parse.Task.completeImmediately(Task.java:444)
E/ParseCommandCache(8040): at com.parse.Task.access$300(Task.java:22)
E/ParseCommandCache(8040): at com.parse.Task$6.then(Task.java:311)
E/ParseCommandCache(8040): at com.parse.Task$6.then(Task.java:308)
E/ParseCommandCache(8040): at com.parse.Task.runContinuations(Task.java:510)
E/ParseCommandCache(8040): at com.parse.Task.access$800(Task.java:22)
E/ParseCommandCache(8040): at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:565)
E/ParseCommandCache(8040): at com.parse.Task$TaskCompletionSource.setResult(Task.java:599)
E/ParseCommandCache(8040): at com.parse.Task$11$1.then(Task.java:493)
E/ParseCommandCache(8040): at com.parse.Task$11$1.then(Task.java:485)
E/ParseCommandCache(8040): at com.parse.Task$10.run(Task.java:448)
E/ParseCommandCache(8040): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
E/ParseCommandCache(8040): at com.parse.Task.completeImmediately(Task.java:444)
E/ParseCommandCache(8040): at com.parse.Task.continueWith(Task.java:318)
E/ParseCommandCache(8040): at com.parse.Task.continueWith(Task.java:329)
E/ParseCommandCache(8040): at com.parse.Task$11.run(Task.java:485)
E/ParseCommandCache(8040): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
E/ParseCommandCache(8040): at com.parse.Task.completeAfterTask(Task.java:477)
E/ParseCommandCache(8040): at com.parse.Task.access$400(Task.java:22)
E/ParseCommandCache(8040): at com.parse.Task$7.then(Task.java:346)
E/ParseCommandCache(8040): at com.parse.Task$7.then(Task.java:343)
E/ParseCommandCache(8040): at com.parse.Task.runContinuations(Task.java:510)
E/ParseCommandCache(8040): at com.parse.Task.access$800(Task.java:22)
E/ParseCommandCache(8040): at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:565)
E/ParseCommandCache(8040): at com.parse.Task$TaskCompletionSource.setResult(Task.java:599)
E/ParseCommandCache(8040): at com.parse.Task$11$1.then(Task.java:493)
E/ParseCommandCache(8040): at com.parse.Task$11$1.then(Task.java:485)
E/ParseCommandCache(8040): at com.parse.Task$10.run(Task.java:448)
E/ParseCommandCache(8040): at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
E/ParseCommandCache(8040): at com.parse.Task.completeImmediately(Task.java:444)
E/ParseCommandCache(8040): at com.parse.Task.continueWith(Task.java:318)
E/ParseCommandCache(8040): at com.parse.Task.continueWith(Task.java:329)
E/ParseCommandCache(8040): at com.parse.Task$11.run(Task.java:485)
E/ParseCommandCache(8040): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/ParseCommandCache(8040): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/ParseCommandCache(8040): at java.lang.Thread.run(Thread.java:841)
答案 0 :(得分:1)
看起来ParseInstallation在Parse DB中不存在...... 因此,我找到的一个解决方案是卸载/安装应用程序。
答案 1 :(得分:1)
强制Parse通过删除文件来重新初始化
public static void removeCurrentInstallation(Context context) {
File filesDir = context.getDir("Parse", Context.MODE_PRIVATE);
boolean exists = filesDir.exists();
File[] files = filesDir.listFiles();
if (exists && filesDir.length() > 0) {
for (File file : files) {
if (file.isFile())
file.delete();
}
}
}
在Application class
中使用它 ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.i("Parse", "Installation saved successfully");
} else {
Log.e("Parse", "Installation failed to save: " + e);
if (e.getCode() == ParseException.OBJECT_NOT_FOUND) {
removeCurrentInstallation(getApplicationContext());
}
}
}
});