Best way to incorporate Volley (or other library) into Android Studio project
Solution 1:
As pointed out by others as well, Volley is officially available on Github:
Add this line to your gradle dependencies for volley:
compile 'com.android.volley:volley:1.0.0'
To install volley from source read below:
I like to keep the official volley repository in my app. That way I get it from the official source and can get updates without depending on anyone else and mitigating concerns expressed by other people.
Added volley as a submodule alongside app.
git submodule add -b master https://github.com/google/volley.git volley
In my settings.gradle, added the following line to add volley as a module.
include ':volley'
In my app/build.gradle, I added a compile dependency for the volley project
compile project(':volley')
That's all! Volley can now be used in my project.
Everytime I want to sync the volley module with Google's repo, i run this.
git submodule foreach git pull
Solution 2:
LATEST UPDATE:
Use the official version from jCenter instead.
dependencies {
compile 'com.android.volley:volley:1.0.0'
}
The dependencies below points to deprecated volley that is no longer maintained.
ORIGINAL ANSWER
You can use this in dependency section of your build.gradle file to use volley
dependencies {
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
}
UPDATED:
Its not official but a mirror copy of official Volley. It is regularly synced and updated with official Volley Repository so you can go ahead to use it without any worry.
https://github.com/mcxiaoke/android-volley
Solution 3:
Nowadays
dependencies {
compile 'com.android.volley:volley:1.0.0'
}
A lot of different ways to do it back in the day (original answer)
-
Add
volley.jar
as library- Download it from: http://api.androidhive.info/volley/volley.jar
- Place it in your
[MyProjectPath]/app/libs/
folder
-
Use the source files from git (a rather manual/general way described here)
- Download / install the git client (if you don't have it on your system yet): http://git-scm.com/downloads
(or 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 (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. - Download / install the git client (if you don't have it on your system yet): http://git-scm.com/downloads
(or via
-
Use gradle via the "unofficial" maven mirror
-
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'
. -
Solution 4:
As of today, there is an official Android-hosted copy of Volley available on JCenter:
compile 'com.android.volley:volley:1.0.0'
This was compiled from the AOSP volley source code.
Solution 5:
UPDATE:
compile 'com.android.volley:volley:1.0.0'
OLD ANSWER: You need the next in your build.gradle of your app module:
dependencies {
compile 'com.mcxiaoke.volley:library:1.0.19'
(Rest of your dependencies)
}
This is not the official repo but is a highly trusted one.