Skip to content Skip to sidebar Skip to footer

Android Volley: Cannot Resolve Symbol Volley

I want to use Volley to send requests from my Android app. I have included this in the build.gradle dependencies { ... compile 'com.android.volley:volley:1.1.0' } I want to

Solution 1:

The correct import is import com.android.volley.toolbox.Volley; (you can check the code here), and this has to be a Context object

Solution 2:

I ran into this problem today. Following works for me:

In Android Studio: Build -> Clean Project, and then Build -> Rebuild Project

Solution 3:

Thanks to Blackbelt's answer, I was able to import the following for Google's standard example https://developer.android.com/training/volley/simple.html

import com.android.volley.toolbox.Volley;
import com.android.volley.RequestQueue;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;

The this in

RequestQueue queue = Volley.newRequestQueue(this);

became

RequestQueue queue = Volley.newRequestQueue(getContext());

also thanks to Blackbelt's answer. I had to play around with where I could call getContext() for my code. I ended up checking if the queue has already been instantiated inside my first request and set it if it hasn't.

Solution 4:

Hanumanjetlibrary.

  String url="http://rt.com/api/my.php";

ApicallAny.ApicallVolleywithoutParams(MainActivity.this,url, new ApicallAny.VolleyCallback() { @Override public void onSuccess(String result) {

//  do stuff here  

    }

    @OverridepublicvoidonError(String result) {
        //  do stuff here
    }
});

#withParams

Map params = new HashMap<>();

params.put("param1","val"); params.put("param2","valx");

String url="http://rt.com/api/my.php"; ApicallAny.ApicallVolleywithParams(MainActivity.this, url,params, new ApicallAny.VolleyCallback() { @Override public void onSuccess(String result) {

// do stuff here } @OverridepublicvoidonError(String result) { // do stuff here } });

Post a Comment for "Android Volley: Cannot Resolve Symbol Volley"