1

我正在尝试使用自述文件中提到的依赖项将 ShowcaseView 库包含到我的项目中

compile 'com.github.amlcurran.showcaseview:library:5.0.0'

但 Android Studio 对此给出了错误。我正在使用 Android Studio 1.0.2。谁能告诉我我在这里想念什么?

错误:无法下载工件“library.aar (com.github.amlcurran.showcaseview:library:5.0.0)”:没有可用于离线模式的缓存版本

4

2 回答 2

5

In your build.gradle include http://jcenter.bintray.com as a repository before mavenCentral like this:

repositories {
    maven { url "http://jcenter.bintray.com" }
    mavenCentral()
}

Use in your project dependencies as usual:

dependencies {
    compile 'com.github.amlcurran.showcaseview:library:5.0.0'
}

Why prior to mavenCentral?

Otherwise gradle will look first in mavenCentral, find ShowCaseView artifact with the same version, but won't find the package and will report an error, without looking for same artifact with another packaging in other repositories.

Additional Hint:

If you face this kind of error for any other libraries go to bintray.com ans search for the library that you want. If it is found there then click on the library and u can find the instructions on how to setup that library. Hope it helps many people who comes and searches for the same query.

于 2015-03-09T07:03:16.637 回答
1

I will assume that your are adding the compile line for the library correctly in the Build.gradle (Module: app) file in the dependency section.

Then make sure of two things:

1)Restart your IDE

2)You have an internet connection.

3)Adding the MavenCentral() to your repositories in the build.gradle (Project: you_project_name) in the buildscript section

repositories {
mavenCentral()
} 

4)Click on Sync Now

Have a look on this answer

于 2015-03-09T07:02:08.440 回答