Volleyを使うのがかなり簡単になってた

以前はAndroid Studioで使うのが面倒くさかった volley ですが、最近は簡単にdependenciesに追加できるようになりました。git submodule addしてsubprojectとして設定してdependenciesに加えるだけ。

ハマりどころしては、volley/build.gradle に指定している compileSdkVersion や buildToolsVersion に従ったSDK/platform toolsをandroid sdk managerでインストールしておく必要があるということですかね。これはメインプロジェクトのバージョンとは違っていたとしてもインストールの必要があります。

設定例:

以下のように、.gitmodulesのほかは二行加えるだけです。

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..d8829b2
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "vendor/volley"]
+	path = vendor/volley
+	url = https://android.googlesource.com/platform/frameworks/volley
diff --git a/app/build.gradle b/app/build.gradle
index 2e5903a..0ac9ca9 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -20,4 +20,5 @@ android {
 
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
+    compile project(':vendor:volley')
 }
diff --git a/settings.gradle b/settings.gradle
index e7b4def..acd337c 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1,2 @@
 include ':app'
+include ':vendor:volley'
diff --git a/vendor/volley b/vendor/volley
new file mode 160000
index 0000000..e542f49
--- /dev/null
+++ b/vendor/volley
@@ -0,0 +1 @@
+Subproject commit e542f4964d2b6668c028edce5afe1fe2faefc64b