【问题标题】:Android add library in gradleAndroid在gradle中添加库
【发布时间】:2015-12-15 10:11:38
【问题描述】:

注意:我的项目是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分钟,最后给了我一个错误:

无法解析 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')
    }
}

感谢您的宝贵时间。

【问题讨论】:

  • mmm...这是在Android Studio 上导入的Eclipse 项目,对吧?
  • @Aspicas 是的,抱歉我忘了提
  • 那么...也许你必须手动导入库,像一个模块,有时这就是问题,尝试像一个模块一样导入库,一些新的项目或库与旧的@987654326不兼容@项目。
  • 我看你以前做过,如果你不知道怎么做,告诉我,我会尽力帮助你。

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


【解决方案1】:

这个工件在 jcenter 中不存在。

com.marshalchen.ultimaterecyclerview

您可以签到:https://bintray.com/bintray/jcenter

您可以尝试使用 maven Central 代替 jcenter。

repositories {
        mavenCentral()
}

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

您可以查看here发布的版本。

【讨论】:

  • 非常感谢您的帮助 :)
猜你喜欢
  • 2015-12-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-17
  • 2015-08-10
  • 2013-07-21
相关资源
最近更新 更多