Fale Fale - 16 days ago 11
Android Question

Gradle returns package does not exists

I'm trying to add the gson library to my android project (I'm devloping using the Andrdoid-studio).

To add the library, I did changed the AppProject/AppName/build.gradle file in this way:

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'

repositories {
mavenCentral()
}

dependencies {
compile files('libs/android-support-v4.jar')
compile 'com.google.code.gson:gson:2.2.4'
}

android {
compileSdkVersion 17
buildToolsVersion "17.0.0"

defaultConfig {
minSdkVersion 4
targetSdkVersion 16
}
}


All seems to work until I try to use it.

When I try to include it with:

import com.google.code.gson;


Gradle complains affirming:

Gradle: error: package com.google does not exist

Answer

Possible duplicate : Specifying Maven dependencies in build.gradle doesn't work

(Using the command line, in the root of your project, run : ./gradlew clean && ./gradlew build)