尝试在空对象引用上调用虚拟方法 'java.lang.String okhttp3.ResponseBody.string()'
Attempt to invoke virtual method 'java.lang.String okhttp3.ResponseBody.string()' on a null object reference
response.body().string()
有问题
在 Whosebug 中搜索了所有 post。
无法解决此问题。
private void signIn() {
Call<ResponseBody> call = ApiClient.getUserService().createUser(client_fullname, email, nationality, phone, dob, password, cpassword);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
System.out.println("The value of response is" + response.isSuccessful());
ResponseBody result = response.body();
try {
myapiResult = result.string();
} catch (IOException e) {
e.printStackTrace();
}
if (response.isSuccessful()) {
clearEditText();
showAlertDialogBox("Sucessfully Submitted", "Thanks for believing us.", 1);
}
else if (myapiResult.equals(email)) {
showAlertDialogBox("Error", "Already Registered.Please Login", 1);
}
您的回复为空,请先检查以避免崩溃。
if(response.body() != null) {
String s = response.body().string();
}
然后你需要从后端发送适当的响应以避免body为空。
response.body().string()
有问题
在 Whosebug 中搜索了所有 post。
无法解决此问题。
private void signIn() {
Call<ResponseBody> call = ApiClient.getUserService().createUser(client_fullname, email, nationality, phone, dob, password, cpassword);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
System.out.println("The value of response is" + response.isSuccessful());
ResponseBody result = response.body();
try {
myapiResult = result.string();
} catch (IOException e) {
e.printStackTrace();
}
if (response.isSuccessful()) {
clearEditText();
showAlertDialogBox("Sucessfully Submitted", "Thanks for believing us.", 1);
}
else if (myapiResult.equals(email)) {
showAlertDialogBox("Error", "Already Registered.Please Login", 1);
}
您的回复为空,请先检查以避免崩溃。
if(response.body() != null) {
String s = response.body().string();
}
然后你需要从后端发送适当的响应以避免body为空。