這是我第一個使用Android Studio的項目,所以如果你覺得這個問題太天真了,那就讓我免費。我試圖在Android Studio(版本0.8.1)中將Cardslib庫包含到我的項目中。最初我試圖通過將下面的行中的build.gradle將其包括:添加Cardslib庫到Android Studio 0.8.1
compile 'com.github.gabrielemariotti.cards:library:1.7.3'
但它返回以下錯誤(在同步)
Error:Failed to find: com.github.gabrielemariotti.cards:library:1.7.3
的我試圖包括jar文件的,
- 從Maven倉庫下載它
- 將jar文件添加到libs文件夾。
- 添加以下行的build.gradle
編譯文件( '庫/庫-1.7.3-sources.jar')`
雖然沒有任何錯誤gradle這個項目同步,但我不能創建簡單的卡片,即仍然不適合我。
我希望第一種方法能夠工作,因爲Android Studio會處理所有事情,但我想我正在做一些可怕的錯誤。
[編輯] - 添加的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')
}
}
安置自己的build.gradle文件。 –
共享build.gradle文件。 – Paritosh