Best way to incorporate Volley (or another library) into an Android Studio project

I have seen various tips on the best way to do this. This question covers the creation of banks. Elsewhere, I saw advice to simply copy the source of the volley into your own project. This section in libraries on android.com looks the most authoritative. However, after compiling the volleyball, I do not have the aal library, whereas this section says that I should.

So my question is: I have an existing Android Studio project with a standard layout and git repository; What should I do to add a volley? Where should I download it? How to add it to Android Studio? What Gradle files, if any, I need to change.

I hope for those of you who have done this several times, it should be bread butter, but I could not find a simple description.

-

Update , at the suggestion of Scott Bart.

The gradle.build file in the volleyball repository has this line.

apply plugin: 'android-library' 

According to the documentation : "Library projects do not generate APKs, they generate .aar package (which is an Android archive)." However, when I create a volleyball project, .aar is not created.

I feel that since Volley is a library project created by the Android team, it is most likely intended to be created and used as a .aar package. Any advice on whether it would be preferable to generate .aar and how to do it would be appreciated.

+80
android-studio android-volley gradle
Jan 11 '14 at 17:28
source share
8 answers

LAST UPDATE:

Use the official version from jCenter instead.

 dependencies { compile 'com.android.volley:volley:1.0.0' } 

The dependencies below indicate an outdated salvo that is no longer supported.

ORIGINAL RESPONSE

You can use this in the dependency section of your build.gradle file to use volley

  dependencies { compile 'com.mcxiaoke.volley:library-aar:1.0.0' } 

UPDATED:

Not the official, but a mirror copy of the official Volley. It is regularly synchronized and updated by the official Volley repository, so you can use it without any problems.

https://github.com/mcxiaoke/android-volley

+121
Jan 11 '14 at 20:48
source share

As others have noted, Volley is officially available on Github :

Add this line to your gradle volleyball dependencies:

compile 'com.android.volley:volley:1.0.0'




To install a volley from a source, read below:

I like to keep the official repository in my application. Thus, I get it from an official source and can receive updates, regardless of anyone, and mitigate the problems expressed by other people.

Added volley as a submodule next to the application.

 git submodule add -b master https://github.com/google/volley.git volley 

The following line has been added to my .gradle settings to add a volley as a module.

 include ':volley' 

In my /build.gradle app, I added a compilation dependency for a volleyball project

 compile project(':volley') 

It's all! Now volleyball can be used in my project.

Every time I want to sync a volleyball module with a Google repo, I launch it.

 git submodule foreach git pull 
+138
Jun 22 '15 at 23:40
source share

Currently

 dependencies { compile 'com.android.volley:volley:1.0.0' } 

Many different ways to do this in a day (original answer)

  • Use source files from git (more manual / general method described here)

    • Download / install the git client (if it is not already installed on your system): http://git-scm.com/downloads (or via git clone https://github.com/git/git ... sry is bad, but could not resist ^^)
    • Run git clone https://android.googlesource.com/platform/frameworks/volley
    • Copy the com folder from [path_where_you_typed_git_clone]/volley/src into your app/src/main/java projects (instead, integrate it if you already have the com !! !! folder ;-))

    Files immediately appear in Android Studio. For Eclipse, you need to right-click in the src folder and first click refresh (or F5 ).

  • Use gradle through the "unofficial" maven mirror

    • In the src/build.gradle project file, add the following hall dependency:

       dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) // ... compile 'com.mcxiaoke.volley:library:1.+' } 
    • Click Try Again , which should immediately appear at the top of the file, or just Build , if not

    The main β€œadvantage” here is that it will allow you to update the version for you, while in two other cases you will have to manually update the salvo.

    At the bottom, this is not officially from Google, but into a third-party weekly mirror.

    But both of these points really correspond to what you need / need. Also, if you do not want updates, just put the desired version there, for example, for example. compile 'com.mcxiaoke.volley:library:1.0.7' .

+26
Oct. 27 '14 at 12:03 on
source share

Today, JCenter has the official version of Volley hosted on Android, which is located in JCenter:

compile 'com.android.volley:volley:1.0.0'

This was compiled from the source code for AOSP volleyball.

+11
Feb 12 '16 at 19:30
source share

UPDATE:

 compile 'com.android.volley:volley:1.0.0' 

OLD ANSWER: You need the following in your build.gradle of your application module:

 dependencies { compile 'com.mcxiaoke.volley:library:1.0.19' (Rest of your dependencies) } 

This is not an official repo, but very reliable.

+5
Jul 22 '14 at 15:58
source share

To enable a volley in an android studio,

  • paste the following command into the terminal (
    git clone https://android.googlesource.com/platform/frameworks/volley ) and run it.

    Contact your Android developer for this.

    It will create the volley folder name in the src directory.
  • Then go to android studio and right click on the project.
  • select "Create" β†’ "Module" in the list.
  • Then click on import an existing project from the list below.
  • you will see the text input area, namely the source directory, browse the folder that you downloaded (salvo), and then click "Finish".
  • You will see volleyball folders in your project view.
  • switch to the Android view and open the build file: gradle (Module: app) and add the following line in the dependency area:

    compile 'com.mcxiaoke.volley: library-aar: 1.0.0'

  • Now synchronize your project, as well as create your own project.

+1
Dec 23 '15 at 7:33
source share

I created Volley as a standalone project. Thus, it is not tied to any project and exists independently.

I also have a Nexus server setup (internal repo), so I can access the compile 'com.mycompany.volley: volley: 1.0.4' volleyball in any project I need.

Whenever I update a Volley project, I just need to change the version number in other projects.

I really like this approach.

0
Sep 17 '15 at 20:05
source share

add

 compile 'com.mcxiaoke.volley:library:1.0.19' compile project('volley') 

in the dependencies in the build.gradle file of your application

DO NOT OPEN the file build.gradle FILE OF YOUR LIBRARY. IT YOUR APP GRADLE FILE ONLY YOU NEED TO NOTIFY

0
Jul 03 '16 at 6:21
source share



All Articles