android - Gradle 无法解决外部依赖

标签 android gradle zbar

出于某种未知原因,Gradle 拒绝下载我放入 gradle.build 文件中的所有依赖项。我正在尝试获取 'me.dm7.barcodescanner:zbar:1.7' 依赖项,但每次我尝试同步我的 gradle 时,它​​只会给我以下错误:

Error:(6, 13) Failed to resolve: me.dm7.barcodescanner:zbar:1.7

它不仅仅是 zbar 库,它是每个库,这不是 com.android 库。我没有处于离线模式,所以也不可能。我的 .build 文件有问题吗?

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')
    compile project(':MetaioSDK')
    compile 'com.android.support:support-v4:22.0.0'
    compile 'me.dm7.barcodescanner:zbar:1.7'
}

android {
    compileSdkVersion 19
    buildToolsVersion "21.1.0"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['../../templatesContent_crossplatform']
        }

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

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
    }
}

最佳答案

好吧,设法修复它。在依赖 block 中添加了这个:

repositories {
    mavenCentral()
}

关于android - Gradle 无法解决外部依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29984078/

相关文章:

java - ZBar 崩溃 Android Studio

java - 如何将 Parcelable 数组列表添加到部分回收器 View 适配器

android - 在没有root的linux/android上为UDP数据包分配传出接口(interface)

Android:根据所选 fragment 更改菜单

java - 如何在父项目中包含子项目的资源?

android - 由于线程 "main"java.util.zip.ZipException : error in opening zip file 中的异常,无法运行 native 应用程序

android lint - 使用 apache odata-client-android 时出现 InvalidPackage 错误

c++ - 在 ZBar 的 C++ API 中禁用解码器类型

Android:您可以在代码中编辑在 xml 中创建的 View 吗?

python - 导入 zbar 会导致 python 以退出代码 139 退出 - 在运行 10.9 的 mac 上可能导致这种情况的原因是什么?