这是我第一个使用Android的项目,所以如果你觉得这个问题很幼稚,就饶了我吧。我正在尝试在Android (版本0.8.1)中将Cardslib库包含到我的项目中。最初,我试图通过在build.gradle中添加以下行来包括它:
compile 'com.github.gabrielemariotti.cards:library:1.7.3'
但是它返回了以下错误(同步时)
Error:Failed to find: com.github.gabrielemariotti.cards:library:1.7.3
我试着把jar文件包括进去,
编译文件(‘libs/library-1.7.3-sources.jar es.jar’)
虽然gradle项目同步没有任何错误,但我无法创建简单的卡片,即仍然不为我工作。
我希望第一种方法能起作用,因为Android会处理所有的事情,但我想我做了一些可怕的错误。
编辑-添加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')
}
}发布于 2014-07-08 08:36:17
在脚本中添加这个块,告诉gradle在哪里可以找到带libs的回购。
repositories {
mavenCentral()
}所以你的剧本会是这样的:
.......
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.github.gabrielemariotti.cards:library:1.7.3'
}
....... https://stackoverflow.com/questions/24554131
复制相似问题