jess ruiz
jess ruiz

Reputation: 31

how do I handle this error make it right?"invalid method declaration; return type required"

how do i fix this error wherein I get "invalid method declaration; return type required" and the error "missing method body or declare abstract"

pls do help. I'll appreciate the kindness.

private void login(final String email, final String password) {
        //Tag used to cancel the request
        String tag_string_req = "req_login";
        progressDialog.setMessage("Logging in....");
        progressDialog.show();

        StringRequest strReq = new StringRequest(Request.Method.POST,
                Utils.LOGIN_URL, new Response.Listener<String>() {

            @Override
            public void onResponse(String response) {
                Log.d(TAG, "Login Response: " + response.toString());

                try {
                    JSONObject jObj = new JSONObject(response);
                    boolean error = jObj.getBoolean("error");

                    //check for error node in json
                    if (!error) {
                        //now store the user in SQLite
                        JSONObject user = jObj.getJSONObject("user");
                        String uName = user.getString("username");
                        String email = user.getString("email");

                        //Inserting row in users table
                        userInfo.setEmail(email);
                        userInfo.setUsername(uName);
                        session.setLoggedin(true);

                        startActivity(new Intent(Login.this, MainActivity.class));
                        finish();
                    } else {
                        //error in login, get the error message
                        String errorMsg = jObj.getString("error_msg");
                        toast(errorMsg);
                    }
                } catch (JSONException e) {
                    //json error
                    e.printStackTrace();
                    toast("Json error: " + e.getMessage());

                }
            }
        }, new Response.ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e(TAG, "Login Error: " + error.getMessage());
                toast("Unknown Error occured");
                progressDialog.hide();
            }

        }) {
            @Override
            protected Map<String, String> getParams() {
                //Posting parameters to login url
                Map<String, String> params = new HashMap<>();
                params.put("email", email);
                params.put("password", password);

                return params;

            }

This is where i get the error:

    //Adding request to request queue
                AndroidLoginController.getInstance().addToRequestQueue(strReq, tag_string_req);

        }

Upvotes: 0

Views: 952

Answers (1)

Mike Nakis
Mike Nakis

Reputation: 61993

you are missing a closing parenthesis after the closing curly bracket ('}') of your Response.Listener. (So, there should be at least two closing curly brackets in the end.)

Upvotes: 1

Related Questions