gpt4 book ai didi

java - 我该如何处理这个错误使其正确 ?"invalid method declaration; return type required"

转载 作者:行者123 更新时间:2023-12-01 08:59:39 28 4
gpt4 key购买 nike

如何修复此错误,其中出现“无效方法声明;需要返回类型”和错误“缺少方法主体或声明抽象”

请帮忙。我将不胜感激。

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;

}

这是我收到错误的地方:

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

}

最佳答案

您的 Response.Listener 的右大括号 ('}') 后面缺少右括号。 (因此,末尾至少应该有两个右大括号。)

关于java - 我该如何处理这个错误使其正确 ?"invalid method declaration; return type required",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41786208/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com