Skip to content

Gson R8 proguard rules (java.lang.runtimeexception: missing type parameter.) #79

@stevdza-san

Description

@stevdza-san

Checklist

  • I have looked into the Readme and Examples, and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

I was using val jwt = JWT(tokenId) to retrieve claims from the tokenId, in the release build of my android studio project, along with R8 enabled. However I've received the following error: java.lang.runtimeexception: missing type parameter.

After adding those three lines of code in the proguard-rules.pro, the error disappeared:

-keep class com.google.gson.reflect.TypeToken
-keep class * extends com.google.gson.reflect.TypeToken
-keep public class * implements java.lang.reflect.Type

I also had to manually add Gson library to my project just to add those rules, since I'm using KotlinX Serialization library.
Is there a way for you to add those rules for Gson, when using R8, so that we don't have to?

Reproduction

  1. Enable R8
  2. Retrieve claims from a tokenId with val jwt = JWT(tokenId)

Additional context

No response

JWTDecode.Android version

2.0.2

Android version(s)

33

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis points to a verified bug in the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions