解析不幸的是应用程序已经停止在后台持续工作(Parse Unfortunately Applicat

2019-10-21 03:15发布

我的Android应用程序不断显示警报“不幸的是应用程序已停止工作”,在后台时。 我的逻辑得到的唯一错误是下面的一个,它是关于解析(parse.com),我用它来获取来自互联网数据库中的一些信息。

我不明白是什么问题。 我从它失去了天,甚至因为这个问题似乎是解析库中,而不是在我的代码

logcat的输出:

10-13 03:50:54.856: E/ParseCommandCache(2568): Failed to run command.
10-13 03:50:54.856: E/ParseCommandCache(2568):
com.parse.ParseException: object not found for update 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.ParseCommand.onPostExecute(ParseCommand.java:399) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.ParseRequest$5.then(ParseRequest.java:314) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.ParseRequest$5.then(ParseRequest.java:311) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$11.run(Task.java:481) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at
com.parse.Task$ImmediateExecutor.execute(Task.java:673) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task.completeAfterTask(Task.java:477) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at
com.parse.Task.continueWithTask(Task.java:353) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at
com.parse.Task.continueWithTask(Task.java:364) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task$9.then(Task.java:410)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$9.then(Task.java:402) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task$11.run(Task.java:481)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$ImmediateExecutor.execute(Task.java:673) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task.completeAfterTask(Task.java:477) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task.access$400(Task.java:22)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$7.then(Task.java:346) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task$7.then(Task.java:343)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task.runContinuations(Task.java:510) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task.access$800(Task.java:22)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$TaskCompletionSource.trySetResult(Task.java:565) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$TaskCompletionSource.setResult(Task.java:599) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$11$1.then(Task.java:493) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task$11$1.then(Task.java:485)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$10.run(Task.java:448) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at
com.parse.Task$ImmediateExecutor.execute(Task.java:673) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task.completeImmediately(Task.java:444) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task.access$300(Task.java:22)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$6.then(Task.java:311) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task$6.then(Task.java:308)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task.runContinuations(Task.java:510) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task.access$800(Task.java:22)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$TaskCompletionSource.trySetResult(Task.java:565) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$TaskCompletionSource.setResult(Task.java:599) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$11$1.then(Task.java:493) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task$11$1.then(Task.java:485)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$10.run(Task.java:448) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at
com.parse.Task$ImmediateExecutor.execute(Task.java:673) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task.completeImmediately(Task.java:444) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task.access$300(Task.java:22)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$6.then(Task.java:311) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task$6.then(Task.java:308)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task.runContinuations(Task.java:510) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task.access$800(Task.java:22)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$TaskCompletionSource.trySetResult(Task.java:565) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$TaskCompletionSource.setResult(Task.java:599) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$11$1.then(Task.java:493) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task$11$1.then(Task.java:485)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$10.run(Task.java:448) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at
com.parse.Task$ImmediateExecutor.execute(Task.java:673) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task.completeImmediately(Task.java:444) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at
com.parse.Task.continueWith(Task.java:318) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at
com.parse.Task.continueWith(Task.java:329) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task$11.run(Task.java:485)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$ImmediateExecutor.execute(Task.java:673) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task.completeAfterTask(Task.java:477) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task.access$400(Task.java:22)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$7.then(Task.java:346) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task$7.then(Task.java:343)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task.runContinuations(Task.java:510) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task.access$800(Task.java:22)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$TaskCompletionSource.trySetResult(Task.java:565) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$TaskCompletionSource.setResult(Task.java:599) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$11$1.then(Task.java:493) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task$11$1.then(Task.java:485)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task$10.run(Task.java:448) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at
com.parse.Task$ImmediateExecutor.execute(Task.java:673) 10-13
03:50:54.856: E/ParseCommandCache(2568):   at
com.parse.Task.completeImmediately(Task.java:444) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at
com.parse.Task.continueWith(Task.java:318) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at
com.parse.Task.continueWith(Task.java:329) 10-13 03:50:54.856:
E/ParseCommandCache(2568):  at com.parse.Task$11.run(Task.java:485)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-13 03:50:54.856: E/ParseCommandCache(2568):   at
java.lang.Thread.run(Thread.java:841)

编辑:我发现,问题出在下面的代码,因为评论的try / catch块不会出现问题。 希望可以有人帮帮我。

这是我的应用程序类的代码:

    package com.alain.ama.caccamo;

import com.crashlytics.android.Crashlytics;
import com.parse.Parse;
import com.parse.ParseACL;
import com.parse.ParseInstallation;
import com.parse.ParseUser;
import android.app.Application;

public class AmaCaccamoApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        Crashlytics.start(this);

       try {            
        // / Add your initialization code here
        Parse.initialize(this, "TM918DSLjSCTe61lDTqwzxGRYe23************", "a5wmBOm7ZKBJfcBAjHW2C1e1Q7Rr************");

        ParseUser.enableAutomaticUser();
        ParseACL defaultACL = new ParseACL();

        // If you would like all objects to be private by default, remove this
        // line.
        defaultACL.setPublicReadAccess(true);

        ParseACL.setDefaultACL(defaultACL, true);
        ParseInstallation.getCurrentInstallation().saveInBackground();


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

Answer 1:

我曾经有过同样的问题。 检查是否为空。 见注释代码:

   private void processPush(Context context, Intent intent) {
    String msg = "";
    try {
        // Added null check here
        if (intent.getExtras().getString("com.parse.Data") !=null) {
            JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data"));
            Iterator itr = json.keys();
            while (itr.hasNext()) {
                String key = (String) itr.next();
                Log.d(TAG, "..." + key + " => " + json.getString(key));
                if (key.equals("customdata")) {
                    msg = json.getString(key);
                }
            }
        }
    } catch (JSONException e) {
        Log.d(TAG, "JSONException: " + e.getMessage());
    }
    generateNotification(context, msg);
}


文章来源: Parse Unfortunately Application has stopped working continuously on background