Since there are many answers about a single approach, but none that is comparing the different ways to get volley up and running, I also put my two cents in. Feel free to edit/enhance this answer as well.
Add it as library – (quick solution)
- Download it from: http://api.androidhive.info/volley/volley.jar
- Place it in your
[MyProjectPath]/app/libs/
folder - In Android Studio
right-click
on it and selectAdd As Library...
Source files from git – (a rather official solution)
- Download / install the git client (if you don’t have it on your system yet): http://git-scm.com/downloads (othervise via
git clone https://github.com/git/git
… sry bad one, but couldn’t resist ^^) - Execute
git clone https://android.googlesource.com/platform/frameworks/volley
- Copy the
com
folder from within[path_where_you_typed_git_clone]/volley/src
to your projectsapp/src/main/java
folder (or integrate it instead, if you already have a com folder there!! ;-))
The files show up immediately in Android Studio. For Eclipse you will have to
right-click
on thesrc
folder and pressrefresh
(orF5
) first.Doing it via git is what is officially suggested in the android tutorials (look here).
Gradle via an “unofficial” mirror – (dynamic solution)
- In your project’s
src/build.gradle
file add following volley dependency:dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) // ... compile 'com.mcxiaoke.volley:library:1.+' }
- Click on
Try Again
which should right away appear on the top of the file, or justBuild
it if not
The main “advantage” here is, that this will keep the version up to date for you, whereas in the other two cases you would have to manually update volley.
On the “downside” it is not officially from google, but a third party weekly mirror.
But both of these points, are really relative to what you would need/want. Also if you don’t want updates, just put the desired version there instead e.g.
compile 'com.mcxiaoke.volley:library:1.0.7'
.