I am trying to download and run an existing android studio project and currently I am getting the error:
error: package com.google.gson does not exist
The java file that needs gson is in the main app section. The gson-2.8.1.jar
file is in a client
library inside of a libs
folder.
So the file structure looks a little like:
project_root
|-- app/
| |-- src/
| |-- main/
| |-- java/
| |-- com.company.stuff/
| |-- controller
| |-- fileThatUsesGson.java
|-- client/
|-- libs/
|-- gson-2.8.1.jar
The app build.gradle
shows:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(path: ':client')
}
The client build.gradle
shows:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/gson-2.8.1.jar')
}
This does seem to be an older project. I had to change compile
to implementation
which seems like it might be part of the problem but I can't seem to figure out how to add those .jar
files.
Any help would be appreciated. Thanks!
Expanding on Mr.AF's answer:
In the app
build.gradle
file I addedsync project with gradle files
andmake project
Original