Reputation: 1931
I just tried to upgrade my dependencies but, the import classes are missing now. I think something broke in this upgraded version.
These are my current Gradle dependencies:
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.code.gson:gson:2.8.6'
And following classes are missing at compilation time Gson
and GsonBuilder
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Can anyone help me, please?
Hint: There are no new imports to load.
Upvotes: 1
Views: 1705
Reputation: 189
This problem seems to happen sometimes when upgrading the IDE, its a Sync Issue
Simple solution:
In build.gradle
implementation 'com.google.code.gson:gson:2.8.9'
[is the version you want, but doesn't work]
Rollback & Sync, Rollforward & Sync
implementation 'com.google.code.gson:gson:2.8.8'
--> Sync --> implementation 'com.google.code.gson:gson:2.8.9'
--> Sync
Should work if your lucky :) If not, invalidate caches, reload and roll back and forth again.
Upvotes: 0
Reputation: 2092
Nothing has changed from version 2.8.5 to 2.8.6 in regards to com.google.code.gson:gson.
Below is the content of the com.google.code.gson:gson:2.8.6 version of the jar. You can see Gson and GsonBuilder classes are present. I don't know which IDE are you using, but you should check how dependencies are resolved in your project.
You might use gradlew dependencies
command and check the dependency tree. Be sure
com.google.code.gson:gson:2.8.6 is properly resolved.
Part of the result of running gradle dependencies
command
compileClasspath - Compile classpath for source set 'main'.
+--- com.squareup.retrofit2:converter-gson:2.9.0
| +--- com.squareup.retrofit2:retrofit:2.9.0
| | \--- com.squareup.okhttp3:okhttp:3.14.9
| | \--- com.squareup.okio:okio:1.17.2
| \--- com.google.code.gson:gson:2.8.5 -> 2.8.6
\--- com.google.code.gson:gson:2.8.6
This is a screenshot of dependencies resolved in IntelliJ for com.google.code.gson:gson:2.8.6, you can clearly see classes are present in correct package:
Upvotes: 0