2

I tried to import android volley into my project, but it failed. I dont know what happened. This is the build.gradle file:

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'
}

And this is the build.gradle for project:

 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
}

I have tried using volley library version 1.1.1, 1.1.0, the one from mcxiaoke, and a few other versions, but none of them worked. I also tried to switch my gradle version, and also tried to create local library using android volley that I cloned. Someone suggested to add maven { url "https://jitpack.io" } to allproject repositories, I also tried it, but it also didnt work. Of course I have also tried to disable offline gradle from Settings menu, but it didnt change anything.

this is the error :

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.

Everytime I changed the volley version the error was just like that too. I dont know what to do now, please help

PS: if i comment/remove the volley dependency my project works 100% fine, and I dont use a proxy-protected internet

1 Answers1

0

Try to add this

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

To your build.gradle and then make a Clean project also Invalidate Cache & Restart from file options should work.

Skizo-ozᴉʞS ツ
  • 19,464
  • 18
  • 81
  • 148