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)

  1. Download it from: http://api.androidhive.info/volley/volley.jar
  2. Place it in your [MyProjectPath]/app/libs/ folder
  3. In Android Studio right-click on it and select Add As Library...

Source files from git – (a rather official solution)

  1. 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 ^^)
  2. Execute git clone https://android.googlesource.com/platform/frameworks/volley
  3. 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-clickon the src folder and press refresh (or F5) first.

    Doing it via git is what is officially suggested in the android tutorials (look here).

Gradle via an “unofficial” mirror – (dynamic solution)

  1. 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.+'
        }
  2. 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'.

android volley

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据