Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

android - Failed to resolve: com.google.code.gson:gson:2.3.1

Error:(25, 13) Failed to resolve: com.google.code.gson:gson:2.3.1

Show in Project Structure dialog

build.gradle:app


apply plugin:'com.android.application'

  android {

   compileSdkVersion 23
    buildToolsVersion "23.0.0 rc2"

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

repositories {
    mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'com.google.android.gms:play-services-base:7.8.0'
compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.google.android.gms:play-services-maps:7.8.0'
compile 'com.google.android.gms:play-services-location:7.8.0'
compile project(':Uni_Image_Lod_Lib')   }

builde.gradle:Project


  // Top-level build file where you can add configuration options common to  all  sub-projects/modules.

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

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}}
  allprojects {
     repositories {
        jcenter()
      }
  }

step follows:

Android Studio Version 1.3.2

Restart computer

Invalidate caches/Restart

up dawn dependency.

but nothing to change. now what will be the solution for this.

After Some Changes

apply plugin:'com.android.application'

  android {

   compileSdkVersion 23
    buildToolsVersion "23.0.1"

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

repositories {
    mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile project(':Uni_Image_Lod_Lib')   }

and get error rebuild

Unresolved dependencies detected while building project in offline mode. Please disable offline mode and try again.

Error:A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugCompile'. Could not resolve com.google.code.gson:gson:2.3.1. Required by: APP:app:unspecified No cached version of com.google.code.gson:gson:2.3.1 available for offline mode. No cached version of com.google.code.gson:gson:2.3.1 available for offline mode.

then i have see in prefrences-> Build, Execution, deployment -> gradle.

project level setting is:

ticked use local gradle distribution

global gradle setting:

offline work is not ticked

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
compile 'com.google.code.gson:gson:2.3.1'

remove .1 and make it compile

'com.google.code.gson:gson:2.3' 

as 2.3.1 is not stable and live yet, that's y its giving your error. also never use + while compiling as its not a best practice as per my knowledge.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...