I\'m trying to use the new Android Studio but I can\'t seem to get it working correctly.
I\'m using the Gson library to serialize/deserialize JSON-o
My answer is basically gathering some of the right but incomplete answers provided above.
Add the following:
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.3'
}
This will allow support for two different ways of adding dependencies. The compile fileTree(dir: 'libs', include: ['*.jar'])
(as @Binod mentioned) tells the compiler to look under the folder libs for ANY jar. It is a good practice to create such a folder 'libs' which will contain the jar packages that our application needs to use.
But this will also allow support for Maven dependency. The compile 'com.google.code.gson:gson:2.3'
(as mentioned by @saneryee) it is another recommended way to add dependencies that are in a central remote repository and not in our /libs "local repository". It is basically telling gradle to look for that version of that package and it's telling the compiler to consider it when compiling the project (having it in the classpath)
PS: I use both