CodesLikeA_Mokey CodesLikeA_Mokey - 1 month ago 33
Android Question

Android Gradle cannot find symbol class Gson

So i added gson-2.2.4.jar to the libs dir (I'm using android studio). My project couldn't find the gson stuff so I added it as a library dependency to my module in the "Project Structure". When I try to run the project, the build is failing with the following errors:

Error:(12, 23) Gradle: package does not exist
Error:(37, 3) Gradle: cannot find symbol class Gson
Error:(37, 19) Gradle: cannot find symbol class Gson

Why can't I get this working? I read elsewhere that gradle is supposed to handle everything automatically if it's put in the lib dir.


Adding it as a dependency in the Project Structure settings is not enough. That setting is only for the IDE. To actually build, Gradle also needs to be aware of it. You must add the .jar file to your build.gradle file like so...

dependencies {
    compile files('libs/gson-2.2.4.jar')