刚刚在asynctask上发布了apk崩溃

时间:2015-01-07 09:38:13

标签: android android-asynctask nullpointerexception

我刚刚在Google Play商店发布了我的应用。我确信apk编写得很好,没有任何崩溃。不幸的是,在我发布测试版的商店后,它在FIRST asynctask上崩溃了。这是我的日志:

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.NullPointerException
at it.mybow.SaronnoCity.Login.RegStep3$Senddata.doInBackground(RegStep3.java:358)
at it.mybow.SaronnoCity.Login.RegStep3$Senddata.doInBackground(RegStep3.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 4 more

这是神秘错误的一类:

class Senddata extends AsyncTask<String, String, String> {

    /**
     * Before starting background thread Show Progress Dialog
     * */
    boolean failure = false;

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(getActivity());
        pDialog.setMessage("Registrazione in corso...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();

    }

    @Override
    protected String doInBackground(String... args) {
        // TODO Auto-generated method stub
        int success;
        MyApplication application;
        application = (MyApplication) getActivity().getApplicationContext();

      //String regId = application.getGCMId();      
        String regId = "Appenaregistrato";
        String nome = application.getnome();
        String sesso = application.getsesso();
        String email = application.getemail();
        String username = application.getusername();
        String password = application.getpassword();
        String telefono = application.gettelephone();
        //Log.d("regId", regId);

        try {
            Log.d("regId", regId);
            Log.d("nome", nome);
            Log.d("sesso", sesso);
            Log.d("email", email);
            Log.d("username", username);
            Log.d("password", password);
            Log.d("telefono", telefono);


        //Aggiungo i parametri generati dalle variabili
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("registration_id", regId));
            params.add(new BasicNameValuePair("nome", nome));
            params.add(new BasicNameValuePair("email", email));
            params.add(new BasicNameValuePair("username", username));
            params.add(new BasicNameValuePair("password", password));
            params.add(new BasicNameValuePair("sesso", sesso));
            params.add(new BasicNameValuePair("telefono", telefono));

            Log.d("request!", "starting");

            //Utilizzo JSON per mandare i dati delle variabili
            JSONObject json = jsonParser.makeHttpRequest(
                   LOGIN_URL, "POST", params);


            // Line 358 ERROR
            Log.d("Login attempt", json.toString());

            //Se va tutto bene... 
            success = json.getInt(TAG_SUCCESS);
            if (success == 3) {
                Log.d("User Created!", json.toString());
                getActivity().finish();
                return json.getString(TAG_MESSAGE);
            }if(success == 0){
                Log.d("Inserire tutti i campi!", json.getString(TAG_MESSAGE));
                return json.getString(TAG_MESSAGE);
            }
            if (success == 1) {
                Log.d("L'username scelto è gia in uso", json.toString());

                return json.getString(TAG_MESSAGE);
            }if(success == 2){
                Log.d("Operazione fallita!", json.getString(TAG_MESSAGE));
                return json.getString(TAG_MESSAGE);

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

        return null;

    }
    /**
     * After completing background task Dismiss the progress dialog
     * **/
    protected void onPostExecute(String file_url) {
        //Funzione dismiss
        pDialog.dismiss();
        if (file_url != null){
            Toast.makeText(getActivity(), file_url, Toast.LENGTH_LONG).show();
        }

    }

};

所以两个人认为这一切都很奇怪: 1)为什么我的应用程序在发布后崩溃,而apk没有? 2)为什么它不会在特定的asyntask上崩溃,但通常在第一个叫做?

感谢所有人。

0 个答案:

没有答案