无法解决Zxing依赖项

时间:2018-09-12 02:42:50

标签: android android-studio build.gradle barcode zxing

一周之内,我在Android Studio上遇到了一些错误。

我想在项目中添加Zxing库依赖项。但是每次我添加依赖项时。我收到此错误

"Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve..."

我确实在要查找的每个依赖项上都删除了带有“实现”的“编译”。

仅供参考:我已经成功添加了Volley Library。没有错误出现。

这是我的TOP build.gradle

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

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


这是我的APP build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28



    defaultConfig {
        applicationId "id.plevia.projectx.app"
        minSdkVersion 18
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"


    }

    buildTypes {
       release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
    }

}

dependencies {
    implementation project(':feature')
    implementation project(':base')
    implementation('com.android.volley:volley:1.1.1')
}



这是我的BASE build.gradle

apply plugin: 'com.android.feature'

android {
    compileSdkVersion 28
    baseFeature true
    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    api 'com.android.support:appcompat-v7:28.0.0-rc02'
    api 'com.android.support.constraint:constraint-layout:1.1.3'
    application project(':app')
    feature project(':feature')
    implementation('com.android.volley:volley:1.1.1')
}



这是我的功能build.gradle

apply plugin: 'com.android.feature'

android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':base')
    implementation('com.android.volley:volley:1.1.1')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

}

上面所有不依赖Zxing的build.gradle脚本。

我要做的就是制作条形码扫描仪,而不必在每次扫描时都按下按钮

谢谢。

1 个答案:

答案 0 :(得分:1)

作为@ Arbaz.in在评论部分的答案。我的问题的答案是 取消选中离线工作选项

文件->其他设置->默认设置->构建,执行,部署->构建工具-> Gradle->取消选中脱机工作选项