org.json.JSONException: End of input at character 0 of, android

后端 未结 2 935
伪装坚强ぢ
伪装坚强ぢ 2021-01-21 17:00

I am implementing an android app and trying to make a register and login screens. my app is connected to a server, here is the part my code that makes error:

pub         


        
相关标签:
2条回答
  • 2021-01-21 17:32

    As you have seen in your logcat 1576-1576/com.example.neshat.androidhive2 D/RegisterActivity﹕ Register Response: which is the result of Log.d(TAG, "Register Response: " + response.toString());, response is an empty string, so your app will get org.json.JSONException: End of input at character 0 of at the line JSONObject jObj = new JSONObject(response);.

    You should check response is not null and not an empty string first.

    0 讨论(0)
  • 2021-01-21 17:36

    If you are using php to get the response, you should check on your php file. I had the same problem as you, i forgot to write the response on my php file. Below is part of my code that i forgot

    $response = new emp();
    $response->success = 1;
    $response->message = "Register success, please login.";
    die(json_encode($response)); 
    
    0 讨论(0)
提交回复
热议问题