com.handmark.PullToRefresh is an excellent library. A pity it’s no longer being maintained, and has no gradle dependency.
Luckily, we can import the libproject “as it is” and compile it using Gradle. These are the steps.
1.- First of all, you need to download the libproject clicking on the “download ZIP” button found in the project’s GitHub site.
2.- Create an empty Android Studio project, let’s name it “PrjLibDeps”. Make sure it compiles succesfully and shows the “Hello World, PrjLibDeps” text before going to next step.
3.- In the project’s root folder, create a folder called “libs”, and place the “pulltorefresh” folder inside. The structure must remain as follows:
| src, res, LICENSE, pom.xml...
4.- Now, inside “pulltorefresh” folder, create a file named “build.gradle”. If there is one, replace it. Copy and paste this dummy content we’re going to change later:
apply plugin: 'com.android.library'
java.srcDirs = ['src']
res.srcDirs = ['res']
5.- Now replace compileSdkVersion, buildToolsVersion, minSdkVersion, and targetSdkVersion with values that are valid in your Android SDK installation. The easiest way is to set the same values found in app/build.gradle file.
6.- Now edit app/build.gradle, and add these dependencies.
// Leave the previous dependencies (if any) unmodified
7.- Edit settings.gradle, located in the project’s root directory. Add these lines
include ‘:app', ':PullToRefresh'
project (':PullToRefresh').projectDir = new File('libs/pulltorefresh')
8.- A yellow message saying “Gradle files have changed since las project sync …” might appear on the upper right. Click on “Sync now” to make gradle synchronize all resources.
9.- After gradle sync has finished, press CMD+F9 to Make the whole project. If you’ve done all steps correctly, you might get success 🙂 At least I could make it work with these exact steps. More import examples can be found at: SO question 1, SO question 2.
Let me know any issues.
Have a nice coding day!!