Volley Android Networking Library

I have few questions around using Volley in my projects:

  • Can this library be used in any Java project or just Android?
  • I see multiple branches here and no documentation on which branch is to start with. Which branch should I use to start with?
  • How do you 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?

  • $ 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, ie volley_20150319.jar , to keep versioning simple.


    Android Studio:

  • Clone the Volley repository via Git.
  • Import the project into Android Studio. (I usually select the project's gradle file when importing in Android Studio)
  • Build the project. (I had to change the gradle build settings to reflect the latest build tools and gradle version, but it's usually up to date).
  • In your file explorer, navigate to [your local path to volley]/build/intermediate/bundles/
  • In both the debug and release folders you'll find a JAR file called classes.jar .
  • Copy either JAR file into your libs/ folder.
  • Gradle sync, and you're done.

  • Eclipse:

  • Clone the Volley repository via Git.
  • Import the project into eclipse.
  • Right-click the project and select Export...
  • Select Java / JAR file .
  • We're only interested in the src folder and nothing else. The easiest way to make sure only it is selected is to deselect the project and then select the src folder inside.
  • Check the Export generated class files and resources option.
  • OPTIONAL: If you want the Javadoc to be visible also select the Export Java source files resources .
  • Create the JAR file and put it in your 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.

    链接地址: http://www.djcxy.com/p/29502.html

    上一篇: OkHttp +使用双向SSL身份验证改进libssl崩溃

    下一篇: 排球Android网络库