首页 > 解决方案 > 所有键和值都必须为非空

问题描述

2021-08-13 14:28:10.414 5005-5092/com.nigoote.peaplesafetyapp E/Volley: [304] NetworkDispatcher.processRequest: 未处理的异常 java.lang.IllegalArgumentException: Request#getParams() 或 Request#getPostParams() 返回包含 null 键或值的映射:(firstname, null)。所有键和值都必须为非空。java.lang.IllegalArgumentException:Request#getParams() 或 Request#getPostParams() 返回了一个包含空键或值的映射:(firstname, null)。所有键和值都必须为非空

这是我得到的错误,导致错误的代码如下:

        RequestQueue requestQueue = Volley.newRequestQueue(CreateNewAcount.this);
        StringRequest request = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                if (response.equals("Successfully_Registered")){
                    Log.d("enock",response+"working");
                    progressDialog.dismiss();```
                    Toast.makeText(CreateNewAcount.this, response, Toast.LENGTH_SHORT).show();
                    startActivity(new Intent(CreateNewAcount.this,LoginActivity.class));
                    finish();
                }else{
                    progressDialog.dismiss();

                    Toast.makeText(CreateNewAcount.this, response, Toast.LENGTH_SHORT).show();

                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                progressDialog.dismiss();
                Toast.makeText(CreateNewAcount.this, error.toString(), Toast.LENGTH_SHORT).show();
            }
        }){ ```

in HahMap the firstname is not null but i don't konw why i get this error 
 ```           @Nullable
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String,String> param = new HashMap<String, String>();
                param.put("firstname",fname);
                param.put("lastname",lname);
                param.put("phonenumber",phone);
                param.put("password",password1);
                param.put("address",address);
                param.put("allergy",allergy);
                return param;
            }
        }; 

请我不知道如何解决它的帮助。

标签: javaandroidfirebaseandroid-studio

解决方案


推荐阅读