4

I import project from eclipse to android studio, and got above message after Sync project with gradle files. I am new with android studio, don't know how to solve this error.

Following is the Gradle file.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'
    defaultConfig {
        applicationId "com.s5.selfiemonkey1"
        minSdkVersion 14
        targetSdkVersion 14
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    }
    productFlavors {
    }
}

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.google.code.gson:gson:2.2.2'
    compile files('libs/AF-Android-SDK.jar')
    compile files('libs/AndroidSwipeLayout-v1.1.8.jar')
    compile files('libs/FlurryAnalytics-5.3.0.jar')
    compile files('libs/android-viewbadger.jar')
    compile files('libs/commons-codec-1.4.jar')
    compile files('libs/google-play-services.jar')
    compile files('libs/okhttp-2.5.0.jar')
    compile files('libs/okio-1.6.0.jar')
    compile files('libs/parcelgen.jar')
    compile files('libs/scribe-1.1.2.jar')
}

Build Gradle from 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.2.3'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Please advice. Thanks in advance.

Amol Patil
  • 985
  • 2
  • 11
  • 43

3 Answers3

3

Since GSon is in mavenCentral , you have to add mavenCentral() in buidscripts phase.

Charlie
  • 568
  • 1
  • 6
  • 13
  • Also one more thing Found out in project settings. In projects tab android plugin repository was set to mavencentral but default library repository was blank, making both same worked for me. – Charlie Sep 11 '15 at 20:09
2

Gson's latest version is currently 2.3.1 https://github.com/google/gson/releases

Try with compile 'com.google.code.gson:gson:2.3.1'

jlhonora
  • 10,179
  • 10
  • 46
  • 70
1

you have to add the Gson library in the dependency using project structure, now to update the gradle, for the add the .jar file to your build.gradle file like

dependencies {
compile files('libs/gson-2.2.4.jar')
}

if it dosent works try changing it to

dependencies{
compile 'com.google.code.gson:gson:2.2.+'
}

make sure you are also connected to the internet so that jars will be downloaded online through maven repo.

Maniya Joe
  • 761
  • 6
  • 24