无法使用Gradle将ViewPagerIndicator添加到应用程序

时间:2015-04-13 21:37:45

标签: android maven gradle android-gradle viewpagerindicator

我正在尝试添加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'

}

感谢您提供的任何帮助

1 个答案:

答案 0 :(得分:23)

您可以查看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()

    }
}