我一直在寻找答案,但是我找不到我的带有commons-io依赖的build.gradle无法正常工作的原因。我目前正在关注本教程:https://guides.codepath.com/android/Basic-Todo-App-Tutorial,并在build.gradle模块文件的dependencies部分中添加行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'
}
答案 0 :(得分:0)
找到答案。问题是我在Android Studio中启用了离线工作。
要禁用此功能,我执行了以下操作:
File->Settings->Build,Execution,Deployment->gradle->untick box that says offline work