Edge case where R8 removes the TypeToken's generic type (while consuming the library's recently updated proguard rules) #2658
Labels
bug
proguard-r8
Issues relating to the use of ProGuard and/or R8, such as problems due to obfuscation
(Originally reported here).
Gson version
2.10.1 + those proguard rules.
Java / Android version
I have tested on Android 34.
Used tools
Description
@Marcono1234 First of all thanks a lot for introducing consumer proguard rules!
I have added the rules to one of my projects. Everything seemed to work fine, but I ran into one issue.
Here's a sample code that makes use of Gson's TypeToken:
MyImplementation
class implements theMyInterface
interface, and this is its only usage in code.Upon minification, R8 removes the
MyImplementation
class completely, whileTypeToken
is being left withjava.lang.Object
as its generic argument:This, in turn, causes a runtime exception:
As a workaround, I currently have to explicitly keep the class:
I'm wondering if more general rule can be used in such cases.
Expected behavior
Run the application without errors.
Actual behavior
The application crash at runtime.
Reproduction steps
I have uploaded a sample project for demonstration.
The text was updated successfully, but these errors were encountered: