【发布时间】:2019-02-21 23:14:36
【问题描述】:
我正在尝试下载并运行现有的 android studio 项目,目前我收到错误:
error: package com.google.gson does not exist
需要gson的java文件在主app部分。 gson-2.8.1.jar 文件位于 libs 文件夹内的 client 库中。
所以文件结构看起来有点像:
project_root
|-- app/
| |-- src/
| |-- main/
| |-- java/
| |-- com.company.stuff/
| |-- controller
| |-- fileThatUsesGson.java
|-- client/
|-- libs/
|-- gson-2.8.1.jar
应用程序build.gradle 显示:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(path: ':client')
}
客户端build.gradle显示:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/gson-2.8.1.jar')
}
这似乎是一个较旧的项目。我不得不将compile 更改为implementation,这似乎是问题的一部分,但我似乎无法弄清楚如何添加那些.jar 文件。
任何帮助将不胜感激。谢谢!
【问题讨论】:
-
这基本上解决了我的问题 stackoverflow.com/a/54818270/5184092
标签: java android android-gradle-plugin gson