This question already has an answer here:
- Volley Android Networking Library 19 answers
I'm new to Android Studio and I want to use Volley library for my app but i can't add the source as a library in Android Studio.
I've searched the web but couldn't find anything. Everywhere is said to import as a library but I don't know how.
I got the volley source from git repository:
https://android.googlesource.com/platform/frameworks/volley
But I don't know how to add it to my project as a library.
UPDATE: Volley is now official and is available through the JCenter. Here's how to import it:
DEPRICATED WAY:
Late to the party, but was able to import it by adding this to the build.gradle file:
Here is the link to unofficial Maven repo
NOTE: Volley v1.0.19 is current as of 02/05/2016. Please go to the Maven Repo (use link above), look up the latest version (line where artifactId =
library
) and update the version in your gradle configuration accordingly.If you don't want to import it as a module but simply use it as a dependency you can create a jar using ant. In your volley directory just type ant jar and you will find a volley.jar in YOUR_VOLLEY_DIRECTORY/bin (you need to install apache ant if you don't have it)
You can copy the jar in the libs directory in your android app project (or create a libs directory if you don't have one) and add the dependency to build.gradle like this
Edit: As pointed out in the comments, this doesn't work anymore.
File -> Import Module...
Select directory where you downloaded Volley and follow all of the directions (you probably won't have to change anything, just click "Next" a bunch.)
Then, start typing your volley stuff:
As you're typing RequestQueue, it might autosuggest it, or it might turn red after you type it (I can't remember for sure). If it autosuggests it, just select it, and you're done. If it's red and underlined, press Alt-Enter, and there should be an option for something like "Add from module 'volley'" Select that, and you're done.
(Sorry if this isn't all exact. It's from memory.)
I know this is a little later than the other 2 answers, but I couldn't get the JAR import method to work, or exporting Volley to Gradle as the latest version kept on producing errors that the Gradle version was too old...
What I did was to create a new package in my project of com.android.volley, and then copy the source code from the Volley package, making sure that you have both volley and volley/toolbox - once I did this the app ran without an issue
I'm not very good at GIT, but there must be a way to export just the package into the root of your Gradle Java source