[英]Add Cardslib library To Android Studio 0.8.1
This is my first project using Android Studio so spare me if you find this question naive. 这是我的第一个使用Android Studio的项目,如果你发现这个问题很幼稚,请不要理我。 I am trying to include the Cardslib library to my project in Android Studio (version 0.8.1). 我想在我的Android Studio项目(版本0.8.1)中包含Cardslib库。 Initially I tried to include it by adding the following line in build.gradle: 最初我尝试通过在build.gradle中添加以下行来包含它:
compile 'com.github.gabrielemariotti.cards:library:1.7.3'
But it returned the following error (upon sync) 但是它返回了以下错误(同步时)
Error:Failed to find: com.github.gabrielemariotti.cards:library:1.7.3
The I tried to include the jar file by, 我试图包括jar文件,
compile files('libs/library-1.7.3-sources.jar')` 编译文件('libs / library-1.7.3-sources.jar')`
Though gradle project sync without any error but I am not able to create simple cards ie still not working for me. 虽然gradle项目同步没有任何错误,但我无法创建简单的卡,即仍然不适合我。
I wanted the first method to work since Android Studio would then handle everything but I guess I am doing something horribly wrong. 我想要第一种方法,因为Android Studio会处理所有内容,但我想我正在做一些可怕的错误。
[Edit] - Adding the build.gradle code [编辑] - 添加build.gradle代码
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.github.gabrielemariotti.cards:library:1.7.3'
}
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
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')
}
}
Add this block in your script to tell gradle where it can find the repo with libs. 在脚本中添加此块以告诉gradle它可以在哪里找到libs的repo。
repositories {
mavenCentral()
}
So your script will be something like this: 所以你的脚本将是这样的:
.......
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.github.gabrielemariotti.cards:library:1.7.3'
}
.......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.