Is there an easier way to add gson to my project?

后端 未结 4 1962
小蘑菇
小蘑菇 2021-01-01 17:00

How do I add gson to my project with gradle? I only see people adding files to their projects. I don\'t want to download the project and put it in mine.

相关标签:
4条回答
  • 2021-01-01 17:20

    In app/build.gradle:

     dependencies {
        compile 'com.google.code.gson:gson:2.8.2'
    }
    
    0 讨论(0)
  • 2021-01-01 17:23

    Add following to project’s build.gradle

    repositories {
        mavenCentral()
    }
    
    dependencies {
        compile 'com.google.code.gson:gson:2.8.0'
    }
    

    Here is the link for more info.

    0 讨论(0)
  • 2021-01-01 17:26

    If you are using Android Studio you can use the following workflow instead of manually changing Gradle files:

    1. File -> Project Structure -> Modules -> app -> Dependencies Tab
    2. Click '+' in the bottom left corner and select "Library dependency"
    3. In the search field type: "gson" and click Search
    4. Select "com.google.code.gson:gson:2.8.5"

    0 讨论(0)
  • 2021-01-01 17:32

    compile is obsolete use implementation instead

    dependencies {
    
        implementation 'com.google.code.gson:gson:2.8.5'
    
    }
    

    P.S. version of 08/07/2019

    0 讨论(0)
提交回复
热议问题