I am trying to import GSON into my project using gradle in android studio. I have used instructions found on google'sGitHub and several stack overflow pages, such as here. However when I go to import into my file using the line
import com.google.gson.Gson;
I still get the following error
Error:(5, 23) error: package com.google.gson does not exist
example from my app's build.gradle
compile 'com.google.code.gson:gson:2.7'
and my settings.gradle
include 'gson:2.7'
Am I missing something?
Open your project. Go to File -> Project Structure... Click on app in the Modules section and switch to the Dependencies tab. Click on the plus icon in the top right corner and select Library dependency. Select the entry for the GSON library from the list and hit OK twice. (Note: the search bar didn't work for me)
Then you are able to use the library just like you described in your question:import com.google.gson.Gson;
Note that after adding the library your project will do a gradle sync which may take a couple of minutes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With