So I am fairly new to Java, and I am trying to add this library to my project. The problem is that Android studio 0.3.6 doesn't have a simple way of doing that and all the answers I searched either reference an older version of Android Studio, or describe how to import an external project (source code, not jar file).
After reading a little, I got to the conclusion that manually adding the jar file would be the best way (manual copy/paste and gradle edits) but as I said, I'm fairly new to this technology and don't know where to place the file nor what lines I need to add to the gradle files.
Can someone help me?
UPDATE 1:
I finally made the IDE recognize the .jar file (I get autocomplete and class recognition). The new problem is that I get the following error when compiling: Gradle: package com.google.gson does not exist
. Here are the steps I took to import the library:
- Creat a folder called libs in the main directory (src/main/libs should be the result)
- Copy the .jar file in that directory
add the following line to the dependencies section in the build.gradle file in your project:
compile files('libs/gson-2.2.4.jar')
. It should look something like this now:dependencies { compile 'com.android.support:support-v13:+' compile files('libs/gson-2.2.4.jar') }
- Recompile the project (not sure if necessary, but I did it)
- Right click on the libs folder and select "Add as Library"