【问题标题】:Can't add ViewPagerIndicator to app with Gradle无法使用 Gradle 将 ViewPagerIndicator 添加到应用程序
【发布时间】:2015-06-19 08:48:18
【问题描述】:

我正在尝试添加 Jack Whartons ViewPagerIndicator 库 https://github.com/JakeWharton/ViewPagerIndicator 到我的应用程序,因为我想为我拥有的 viewpager 使用圆形指示器。但是我无法将它添加到我的应用程序中。 我已按照本教程进行操作 - Using ViewPagerIndicator library with Android Studio and Gradle

但是我得到了这个错误

    Error:Artifact 'library.aar (com.viewpagerindicator:library:2.4.1)' not found.
Searched in the following locations:
    https://jcenter.bintray.com/com/viewpagerindicator/library/2.4.1/library-2.4.1.aar

如果我在我的 gradle 中删除 jCenter() 代码,那么它可以工作,但我包含的其他依赖项没有,所以我不确定如何让所有依赖项一起工作。

这是我的顶级 gradle 文件

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        maven { url "http://dl.bintray.com/populov/maven" }
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

    }
}

这是我的模块:app gradle 文件

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "co.app.al.app"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.afollestad:material-dialogs:0.6.2.3'
    compile files('libs/volley.jar')
    compile 'uk.co.chrisjenx:calligraphy:2.0.2'
    compile 'com.viewpagerindicator:library:2.4.1@aar'

}

感谢大家的帮助

【问题讨论】:

标签: android maven gradle android-gradle-plugin viewpagerindicator


【解决方案1】:

你可以查看maven仓库或者jcenter:

http://search.maven.org/#search%7Cga%7C1%7Ccom.viewpagerindicator

https://bintray.com/bintray/jcenter/com.viewpagerindicator%3Alibrary/view#files

2.4.1 中有一个库工件,但它不是 AAR 文件。

您必须使用替代存储库 maven { url "http://dl.bintray.com/populov/maven" },但顺序很重要。

更改您的脚本:

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

    }
}

【讨论】:

  • 它对我不起作用。有任何想法吗?我有这种方式
  • 天啊!!!我一整天都在处理这个问题,我无法添加 VIewPagerINdicator(使用 gradle)!在网站上尝试其他答案。我要放弃了。但是你的回答救了我。不同的是顺序!!第一行和第二行。就这样!!非常感谢:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多