Android Gradle找不到符号类Gson [英] Android Gradle cannot find symbol class Gson
问题描述
错误:(12,23)Gradle:包com.google.gson不存在
错误:(37,3)Gradle:找不到符号类Gson
错误:(37,19)Gradle:找不到符号类Gson
为什么我无法工作?我在其他地方读过,如果将gradle放在lib目录中,它应该自动处理所有内容。
将它添加为依赖项项目结构设置是不够的。该设置仅适用于IDE。为了实际构建,Gradle还需要了解它。你必须像这样将.jar文件添加到你的build.gradle文件中......
依赖关系{
编译文件('libs / gson-2.2.4.jar')
}
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 com.google.gson 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')
}
这篇关于Android Gradle找不到符号类Gson的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!