简体   繁体   中英

gradle android studio 2.3: failed to resolve 'com.google.code.gson:gson:2.8.0'

i'm facing the gradle error failed to resolve while including gson libraries.

I already checked for similar problem here , here and here but none of the solution proposed was suitable to me, i continue receiving the same error.

My build.gradle module:

android {
    compileSdkVersion 24
    buildToolsVersion '25.0.0'
}

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.code.gson:gson:2.8.0'
}

build.gradle project

buildscript {
repositories {
    mavenCentral()
    jcenter()
}
allprojects {
repositories {
    mavenCentral()
    jcenter()
}

As suggested in the answers it should be enough jcenter repository, as it is a superset of mavenCentral, i tried also different versions of gson, adding "+" et cetera but nothing is working.

Thanks in advance guys :)

尝试在您的应用程序级 build.gradle 文件中使用它

compile 'com.google.code.gson:gson:2.7'

Dear Fabio Add like this

compile 'com.android.support:multidex:1.0.1'
compile 'com.google.code.gson:gson:2.8.0'

see in attached snap在此处输入图片说明

Thanks

Try put this line in the build.gradle (Module:app) inside dependecies:

compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'

Here is an example:

Example project with the gson library added

Try using the previous version of library , if still not working then download the .jar library file from Here and add it to your project. Also check out the possible solutions over here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM