Pulltorefresh add to gradle

匿名 (未验证) 提交于 2019-12-03 01:57:01

问题:

can anyone help me add this library in build.gradle Android Studio.

https://github.com/chrisbanes/Android-PullToRefresh 

I know it is deprecated but I want to use it, I would appreciate if someone could help me

what to write in

dependencies { compile 'com.android.support:support-v4:18.0.0' compile 'com.android.support:appcompat-v7:+' compile '????' } 

as mentioned I want to use the deprecated library not new Actionbar-Pulltorefresh. tried to google it but couldn't find any help.

回答1:

I suggest you to use ActionBarPullToRefresh (same author).

However, if you would like to use PullToRefresh, you have to clone the lib locally in a folder, and then add it as local dependency. This lib isn't on Central Maven as aar.

root   app     build.gradle   lib     pull       src       res       build.gradle   settings.gradle 

In you app/build.gradle you have to add:

dependencies {     // Library     compile project(':lib:pull') } 

In lib/pull/build.gradle you have to define it as library and specify the right sourceset (it is a gist):

apply plugin: 'android-library'  android {     compileSdkVersion 19     buildToolsVersion "19.0.1"      sourceSets {         main {             manifest.srcFile 'AndroidManifest.xml'             java.srcDirs = ['src']             resources.srcDirs = ['src']             aidl.srcDirs = ['aidl']             renderscript.srcDirs = ['src']             res.srcDirs = ['res']             assets.srcDirs = ['assets']         }     } } 

In settings.gradle:

include ':lib:pull' ,':app' 


回答2:

Easiest way to add ActionBar-PullToRefresh to your project is via Gradle, you just need to add the following dependency to your build.gradle

dependencies {       repositories {         mavenCentral()     }     compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+' } 

Rest gradle will do all work for you.



回答3:

I've succesfully imported the libproject in Android Studio 1.0. The steps are the following

1.- Download and install PullToRefresh from the official GitHub. Unzip it. 2.- Create an empty Android Studio project. Mine is named "PrjLibDeps" 3.- In project's root folder, create a folder named "libs". Inside libs/, copy a "pulltorefresh" folder containing the unzipped file. Structure remains as shown below:

PrjLibdeps |   settings.gradle |   build.gradle |   libs       |  pulltorefresh             | src, res, LICENSE, pom.xml... |  app/ |   build.gradle |   src | ... 

4.- Create a build.gradle file inside "pulltorefresh" folder. Copy-paste this sample code and set proper values to compileSdkVersion, buildToolsVersion, minSdkVersion, targetSdkVersion (just copy them from app/build.gradle)

apply plugin: 'com.android.library' dependencies {    compile 'com.android.support:support-v4:21.0.3' } android {   compileSdkVersion 20   buildToolsVersion "20.0.0"   defaultConfig {      minSdkVersion 9      targetSdkVersion 20   }   sourceSets {     main {        manifest.srcFile 'AndroidManifest.xml'        java.srcDirs = ['src']        res.srcDirs = ['res']     }   } } 

5.- on app/build.gradle

dependencies {    compile project(":PullToRefresh") } 

6.- Now, on project_root/settings.gradle:

include ‘:app', ':PullToRefresh' project (':PullToRefresh').projectDir = new File('libs/pulltorefresh') 

7.- "Sync now" 8.- CMD+F9 (Make project)

Hope it helps! more detailed info in my blog



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!