Mapbox-java incompatible with gson 2.13.0 and up - call to internal GSON classes that were renamed

Open
#1,614 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
java
Domain
mobile-dev

Research direction

Start with services-geocoding/src/main/java/com/mapbox/api/geocoding/v5/SingleElementSafeListTypeAdapter.java at the referenced import and compare its GSON usage with the GSON 2.13.0 release notes. Reproduce the R8 missing-class error with GSON 2.13.0 or newer, then verify that the geocoding service builds without that error.

Written by the indexing model from the issue text.

Description

Attempted upgrading GSON (for internal app use and third-party integration requiring a newer version), but encountered issues with mapbox-java. R8 began reporting missing classes due to the following reference:

https://github.com/mapbox/mapbox-java/blob/977651247bcd5dd642de1dd5fd3093d00152099b/services-geocoding/src/main/java/com/mapbox/api/geocoding/v5/SingleElementSafeListTypeAdapter.java#L6

The root cause is the renaming of internal classes in GSON version 2.13.0:

The internal classes $Gson$Types and $Gson$Preconditions have been renamed to remove the $ characters. Since these are internal classes (as signaled not only by the package name but by the $ characters), client code should not be affected. If your code was depending on these classes then we suggest making a copy of the class (subject to the license) rather than depending on the new names.

r8 error:

ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in REDACTED/missing_rules.txt.
ERROR: R8: Missing class com.google.gson.internal.$Gson$Types (referenced from: com.google.gson.TypeAdapter com.mapbox.api.geocoding.v5.SingleElementSafeListTypeAdapter$1.create(com.google.gson.Gson, com.google.gson.reflect.TypeToken))

Dominant language
Java
Stars
438
Forks
117
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mapbox/mapbox-java

All issues in mapbox/mapbox-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.