Search code examples
android-studioundefined-symbol

Android Studio Cannot resolve symbol StringRequest, POST, or Response


I am writing a java class on android studio to connect with a mysql database, but i keep receiving "cannot resolve symbol" error. No idea why. Any Help. Here is a part of the program:

import java.lang.reflect.Method;
import java.net.ResponseCache;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import java.util.HashMap;
import java.util.Map;

public class RegisterRequest extends StringRequest {
    private static final String REGISTER_REQUEST_URL = "****/Register.php";
    private Map<String, String> params;
    public RegisterRequest(String username, String password, String email, Response.Listener<String> listner){
        super(Method.POST, REGISTER_REQUEST_URL, listner, null);
        params = new HashMap<>();
        params.put("username",username);
        params.put("password",password);
        params.put("email",email);
}
    @Override
    public Map<String, String> getParams() {
        return params;
 }
 }

I receiving error "Cannot resolve symbol" for: StringRequest, Response, POST Also error "Method does not override Method from it superclass" for: @Override

Note: all volley imports are marked as unused.

Any Help ?!!


Solution

  • To solve this issue:

    • download the volley library and create a libs folder in your app directory
    • then copy and paste the volley library into the libs folder you created.
    • Finally, right click on the volley library and select add as a library and clean your project.

    If an error remains, press ALT + Enter at each error. It may occur where super(Method.POST, .. can give you an error change it to :

    super(Request.Method.POST