AndroidStudio gradle sync : failed to resolve

2019-08-10 22:04发布

I have new clear android app. I want to add volley to my app to make HTTP request. I am developing app with Android studio using Gradle. Here is screenshot for my app: enter image description here

Ass you see i am going to add volley to my app adding this line of code com.mcxiaoke.volley:library-aar:1.0.0 to build.gradle file

I tried to add Retrofit too. But it gives same type of error: Failed to resolve: bla bla bla.

So i think in my situation gradle can not sync any other library different than com.android......

And i have tried add this lines of code to my build.gradle too. but nothing is changing

 buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
    repositories {
        mavenCentral()
    }
}

Please advise

Edit: After comments added build.gradle files for project and for module. Project:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Module:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "domain.testgradle"
        minSdkVersion 11
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.mcxiaoke.volley:library:1.0.19'
}

3条回答
Fickle 薄情
2楼-- · 2019-08-10 22:34

You can use

com.mcxiaoke.volley:library-aar:1.0.1

Or its latest version (Not aar)

compile 'com.mcxiaoke.volley:library:1.0.19'

And set

buildToolsVersion "23.0.1"

and use

'com.google.code.gson:gson:2.3'
查看更多
爷的心禁止访问
3楼-- · 2019-08-10 22:36

Volley is now published by the Android Open Source Project on jCenter:

dependencies {
    compile 'com.android.volley:volley:1.0.0'
}
查看更多
贼婆χ
4楼-- · 2019-08-10 22:52

Add this

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.mcxiaoke.volley:library:1.0.19'
}
查看更多
登录 后发表回答