我试图将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
}
我已经尝试使用排球库版本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:如果我评论/删除凌空依赖,我的项目可以100%正常运行,并且我不使用受代理保护的互联网
答案 0 :(得分:0)
尝试添加此
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}}
对于您的build.gradle
,然后使Clean project也无效,缓存和从文件重新启动选项应该起作用。