【问题标题】:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.volley:volley:1.1.1无法解析 ':app@debug/compileClasspath' 的依赖关系:无法解析 com.android.volley:volley:1.1.1
【发布时间】:2018-10-15 19:47:12
【问题描述】:

我尝试将 android volley 导入我的项目,但失败了。我不知道发生了什么。这是 build.gradle 文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.root.wifi1"
        minSdkVersion 22
        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 'com.android.support.constraint:constraint-layout:1.1.3'
    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'
}

这是项目的 build.gradle:

 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()
        //maven { url "https://jitpack.io" }
    }
}

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

我尝试过使用 volley library 版本 1.1.1、1.1.0、mcxiaoke 的版本以及其他几个版本,但都没有工作。我还尝试切换我的 gradle 版本,并尝试使用我克隆的 android volley 创建本地库。有人建议将maven { url "https://jitpack.io" } 添加到所有项目存储库中,我也尝试过,但也没有用。当然,我也尝试过从设置菜单中禁用离线 gradle,但它并没有改变任何东西。

这是错误:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.volley:volley:1.1.1.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.volley:volley:1.1.1.
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.volley:volley:1.1.1.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.volley:volley:1.1.1.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.volley:volley:1.1.1.

每次我更改凌空版本时,错误也是如此。 我现在不知道该怎么办,请帮忙

PS:如果我评论/删除 volley 依赖项,我的项目可以 100% 正常工作,而且我不使用受代理保护的互联网

【问题讨论】:

    标签: android dependencies android-volley


    【解决方案1】:

    尝试添加这个

    allprojects {
     repositories {
         jcenter()
         maven {
             url "https://maven.google.com" 
         }
     }}
    

    到您的build.gradle,然后创建一个Clean project 也可以使缓存无效并从文件选项重新启动。

    【讨论】:

    • 还是不行。事实证明,当我尝试使用另一个库时,它无法编译任何远程库。对此有任何线索吗?
    • 还有同样的问题吗?
    • 您找到解决方案了吗?
    猜你喜欢
    • 2018-12-15
    • 1970-01-01
    • 2018-08-26
    • 1970-01-01
    • 2022-08-15
    • 2018-04-10
    • 2018-06-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多