$ git clone https://android.googlesource.com/platform/frameworks/volley
$ cd volley
$ android update project -p .
$ ant jar
Then, copy bin/volley.jar
into your libs/
folder and off you go!
source
In the Volley lesson, Google instructs as to either add Volley to our project as an Android Library project or as a .jar
file.
Here's how to create the Volley .jar
file using Android Studio or Eclipse:
NOTE:
In both cases I suggest renaming the .jar
file to the date of Volley's latest commit, i.e. volley_20150319.jar
, to keep versioning simple.
[your local path to volley]/build/intermediate/bundles/
debug
and release
folders you'll find a JAR file called classes.jar
.libs/
folder.libs/
folder.1) Is this library can also be used as networking library in normal Java projects also OR is it strictly for Android Only
It is for Android only, as it depends on Android-specific classes. You can tell this by looking at the source code, for stuff like RequestQueue
.
2) I see multiple branches here and no documentation on which branch is to start with. Which branch should I use to start with?
The instructions from the Google I|O presentation were to just clone the git
repo, which would pull from the master
branch by default.
3) How to integrate this library in your own project? What approach is better: Make Volley as a standalone library project and spin a jar and put it in your project or Copy the all source code inside your project?
The instructions from the Google I|O presentation were to add the source code to your project. Personally, I find this to be a bizarre approach.
you can download the volley.jar
Source : AndroidHive
copy theVolley.jar
to libs
Then
Right Click volley.jar
->
Add As Library
The Volley library is now published by the Android Open Source Project:
dependencies {
implementation 'com.android.volley:volley:1.1.0'
}
UPDATE: Volley is now official and is available through the JCenter. Here's how to import it:
compile 'com.android.volley:volley:1.0.0'
DEPRICATED WAY:
If you're using Gradle, you can import Volley from here.
dependencies {
compile 'com.mcxiaoke.volley:library:1.0.+'
}
Note
This is an unofficial mirror (with some minor bugfix, see Changelog for details.) for android volley library, the source code will synchronize periodically with the official volley repository.
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.
[MyProjectPath]/app/libs/
folderright-click
on it and select Add As Library...
git clone https://github.com/git/git
... sry bad one, but couldn't resist ^^)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 projects app/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 the src
folder and press refresh
(or F5
) first.
Doing it via git is what is officially suggested in the android tutorials (look here).
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 just Build
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'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With