1.下載Volleyhtml
1 git clone https://android.googlesource.com/platform/frameworks/volley
2.進入Volley目錄android
1 cd volley/
3.運行git
1 gradle build
參考網上帖子,這命令可直接運行,但由於我沒配置ANDROID_HOME環境變量,致使報錯github
1 FAILURE: Build failed with an exception. 2 3 * What went wrong: 4 A problem occurred configuring root project 'volley'. 5 > SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable. 6 7 * Try: 8 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 9 10 BUILD FAILED 11 12 Total time: 4.523 secs
所以,寫入一個local.properties文件到volley目錄下ide
local.properties很簡單,就一行gradle
1 sdk.dir=/Users/users/Library/Android/sdk
從新運行ui
1 gradle build
這時候,gradle會下載很是多的依賴包(查看build.gradle看到volley中使用的gradle版本是1.3.1,但我本身系統自己有2.2.1版本的,因此直接修改了此版本號,但在運行過程當中,出現各類問題,所以後面又改1.3.1版本)google
運行到lint指令時,會報錯spa
1 :lint 2 Ran lint on variant release: 2 issues found 3 Ran lint on variant debug: 2 issues found 4 Wrote HTML report to file:/Users/users/github/volley/build/outputs/lint-results.html 5 Wrote XML report to /Users/users/github/volley/build/outputs/lint-results.xml 6 :lint FAILED
官方給出解決辦法是在build.gradle中添加lint配置,以下.net
1 Fix the issues identified by lint, or add the following to your build script to proceed with errors: 2 ... 3 android { 4 lintOptions { 5 abortOnError false 6 } 7 } 8 ...
但我看了
/Users/users/github/volley/build/outputs/lint-results.xml
其實只是由於AndroidManifest文件中少了一個權限
1 <uses-permission android:name="android.permission.USE_CREDENTIALS" />
添加以上權限到volley/src/main/AndroidManifest.xml文件中,再次運行 gradle build命令,等待很是長一段時間,終於生成對應的jar文件,位於目錄:volley/build/intermediates/bundles/release/classes.jar
說明:目前volley已經不支持ant構建,以前的構建方式
1 android update project -p . 2 3 ant jar
這種方式已經不能使用,需注意(其實第一行命令就會報錯缺乏AndroidManifest文件,生成不了local.properties)
參考資料:
Volley官方教程:https://developer.android.com/training/volley/index.html
Volley構建及使用博客:http://androidsrc.net/android-volley-library-tutorial/