问题描述
我想从https://github.com/chrisbanes/ActionBar-PullToRefresh/wiki/QuickStart-ABC.我只是做了开关从Eclipse中的Android工作室,这样我完全陌生AS和摇篮。
chrisbanes在网站上写道:
相关性{
mavenCentral()
编译com.github.chrisbanes.actionbarpulltorefresh:超ABC:+
}
这是否意味着我没有下载库和摇篮照顾它,使我始终拥有最新版本?我只是不知道从哪里把上面一行。我有一个看起来像我的根2 gradle.build文件之一:
//顶级构建文件,你可以到各子项目/模块添加常用的配置选项。
buildscript {
库{
mavenCentral()
}
依赖{
类路径com.android.tools.build:gradle:0.8.+
}
}
和一个在我的项目,看起来像:
应用插件:'机器人'
依赖{
编译文件树(导演:库,包括:的* .jar)
编译com.android.support:support-v4:18.0.+
编译com.android.support:appcompat-v7:18.0.+
}
安卓{
compileSdkVersion 19
buildToolsVersion19.0.1
sourceSets {
主要 {
manifest.srcFile的AndroidManifest.xml
java.srcDirs = ['src'中]
resources.srcDirs = ['src'中]
aidl.srcDirs = ['src'中]
renderscript.srcDirs = ['src'中]
res.srcDirs = ['水库']
assets.srcDirs = ['资产']
}
//移动测试,测试/ java中,测试/ RES等...
instrumentTest.setRoot(测试)
//将建设各类建设类型/<类型>
//例如,构建类型/调试/ java中,构建类型/调试/ AndroidManifest.xml中,...
//这会将他们从src下他们默认位置/<类型> / ...这将
//与SRC /冲突正在使用的主要来源集中。
//添加新的构建类型或产品的口味应附有
//通过类似定制。
debug.setRoot(集结类型/调试)
release.setRoot(集结类型/释放)
}
}
我一定要在某处添加存储库?
当你把此行的项目,它将正常工作 build.gradle
,在依赖
部分:
编译com.github.chrisbanes.actionbarpulltorefresh:超ABC:+
此外,添加:
库{
mavenCentral()
}
所以:
库{
mavenCentral()
}
依赖{
编译文件树(导演:库,包括:的* .jar)
编译com.android.support:support-v4:18.0.+
编译com.android.support:appcompat-v7:18.0.+
编译com.github.chrisbanes.actionbarpulltorefresh:超ABC:+
}
摇篮就会自动下载所需要的资源,为你。
I am trying to implement ActionBar-PullToRefresh from https://github.com/chrisbanes/ActionBar-PullToRefresh/wiki/QuickStart-ABC. I just made the switch from Eclipse to Android-Studio so I am totally new to AS and Gradle.
chrisbanes writes on the site:
dependencies {
mavenCentral()
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
}
Does this mean that I don't have to download the library and Gradle takes care of it so that I always have the latest version? I just don't know where to put the above line. I have two gradle.build files one in my root that looks like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
and the one in my project which looks like:
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:18.0.+'
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Do I have to add a repository somewhere?
It will work when you put this line in your project build.gradle
, in the dependencies
section:
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
Also, add:
repositories {
mavenCentral()
}
So:
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
}
Gradle will download the needed resources automatically for you.
这篇关于加入GitHub的库依赖于Android的Studio项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!