androidgson

Gson library in Android Studio


Can someone give me step by step guide to add the Gson library to an Android project?

I tried the JSON built-in library but that seems to be a bit tedious right now. I saw a couple of examples based on Gson, and that seems really easy.


Solution

  • Add following dependency to build.gradle:

    implementation 'com.google.code.gson:gson:2.11.0'
    

    Or download the JAR file from Maven by clicking a release and finding the .jar file.

    Replace 2.8.7 with the latest version from Maven.

    Visit the GitHub repo for documentation and more.