【问题标题】:Dependency Error with common.io Librarycommon.io 库的依赖错误
【发布时间】:2018-07-31 16:24:03
【问题描述】:

我现在一直在寻找答案,但我找不到为什么我的 build.gradle 与 commons-io 依赖项不起作用的原因。我目前正在关注本教程:https://guides.codepath.com/android/Basic-Todo-App-Tutorial 并在我的 build.gradle 模块文件的依赖项部分中添加行 implementation 'org.apache.commons:commons-io:1.3.2' 会给我一个错误:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve org.apache.commons:commons-io:1.3.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve org.apache.commons:commons-io:1.3.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve org.apache.commons:commons-io:1.3.2.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve org.apache.commons:commons-io:1.3.2.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve org.apache.commons:commons-io:1.3.2.
Open File
Show Details

我也尝试过从 2.1-2.6 更改实现的版本,但这也不起作用。从其他线程中,也有帖子说要使用 commons-io:commons-io:(version) 但仍然弹出相同的错误。我还尝试将 mavenCentral() 调用添加到存储库方法中的两个 build.gradle 文件,但它仍然显示相同的错误。

这是我的构建 gradle 文件。

构建 gradle(项目)

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

buildscript {

    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

repositories{

    mavenCentral()
}

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

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

构建 gradle(模块)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.test.testing"
        minSdkVersion 15
        targetSdkVersion 27
        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 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    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'
    implementation 'org.apache.commons:commons-io:1.3.2'
}

【问题讨论】:

  • 你的应用 gradle 文件是什么样的?
  • 请发布您的 build.gradle 文件
  • 使用 gradle 文件更新。

标签: android dependencies build.gradle implementation


【解决方案1】:

找到答案。问题是我在 Android Studios 中启用了离线工作。

要禁用此功能,我执行了以下操作:

File->Settings->Build,Execution,Deployment->gradle->untick box that says offline work

【讨论】:

    猜你喜欢
    • 2016-06-11
    • 1970-01-01
    • 2015-09-29
    • 2014-12-13
    • 1970-01-01
    • 1970-01-01
    • 2018-04-10
    • 2015-02-10
    • 2020-01-28
    相关资源
    最近更新 更多