Android在gradle中添加库

标签 android android-studio gradle android-recyclerview build.gradle

注意:我的项目是eclipse,用gradle迁移到android studio

我尝试使用 this库,我添加了以下代码,就像他们在链接中建议的那样:

repositories {
        jcenter()
    }

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':Library-PullToRefresh')
    compile project(':google-play-services_lib')
    compile project(':Library-UniversalImageLoader')
    compile 'com.android.support:support-v4:19.0.+'
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:cardview-v7:22.0.0'
    compile 'com.android.support:recyclerview-v7:22.0.0'
    compile 'com.marshalchen.ultimaterecyclerview:library:0.3.17' //here
}

之后,我尝试同步 gradle。花了将近30分钟,最后给了我一个错误:

unable to resolve com.marshalchen.ultimaterecyclerview:library:0.3.17

我应该做什么?

这是我的 gradle 文件的其余部分,它是一个标准文件:

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    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')
    }
}

感谢您的宝贵时间。

最佳答案

jcenter 中不存在此 Artifact 。

com.marshalchen.ultimaterecyclerview

您可以 checkin :https://bintray.com/bintray/jcenter

你可以尝试使用mavencentral代替jcenter。

repositories {
        mavenCentral()
}

dependencies{
   compile 'com.marshalchen.ultimaterecyclerview:library:0.3.11
}

您可以查看已发布的版本here .

关于Android在gradle中添加库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32648998/

相关文章:

Mac崩溃后Android模拟器状态栏渲染困惑

gradle - 直接从命令行运行 Gradle 插件

gradle - 无法访问nexus存储库以下载依赖项

Android Intent 和回调

android - 更新 studio 3.4 后找不到参数的 leftShift() 方法

android - Jenkins 无法识别自定义 Gradle 任务

android - Gradle图书馆冲突

java - 在 Android 应用程序中存储文本数据的最佳方式?

android - "realm migration needed",从 Realm 数据库中检索值时 android 出现异常

android - 在 Android 中以 pdu 模式发送短信