Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 tasks done
stevdza-san opened this issue Dec 6, 2023 · 6 comments
Open
5 tasks done
Labels
bug This points to a verified bug in the code

Comments

@stevdza-san
Copy link

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

@stevdza-san stevdza-san added the bug This points to a verified bug in the code label Dec 6, 2023
@PrimozNChain
Copy link

Thank you for the fix, didn't know I was the only one with this issue.

@almasmith
Copy link

Thank you! Just got bit by this bug. Unfortunately made it to production 😬 and this post saved the day.

@dgelormini
Copy link

Ran into this after upgrading to AGP 8 recently; my guess is that (in my case) this is appearing now due to R8 fullMode being enabled by default. https://r8.googlesource.com/r8/+/refs/heads/master/compatibility-faq.md#r8-full-mode has more details

@angusryer
Copy link

Ran into this after upgrading to AGP 8 recently; my guess is that (in my case) this is appearing now due to R8 fullMode being enabled by default. https://r8.googlesource.com/r8/+/refs/heads/master/compatibility-faq.md#r8-full-mode has more details

It says we have to enable R8's fullMode manually with android.enableR8.fullMode=true in gradle.properties. The first paragraph states that they leave fullMode off by default to ease the migration from ProGuard to R8.

@dgelormini
Copy link

Ran into this after upgrading to AGP 8 recently; my guess is that (in my case) this is appearing now due to R8 fullMode being enabled by default. https://r8.googlesource.com/r8/+/refs/heads/master/compatibility-faq.md#r8-full-mode has more details

It says we have to enable R8's fullMode manually with android.enableR8.fullMode=true in gradle.properties. The first paragraph states that they leave fullMode off by default to ease the migration from ProGuard to R8.

When upgrading from AGP 7.x to AGP 8.x (which is the update I just did when I encountered this), the docs here say the new default value is true https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes#default-changes

In my case, setting android.enableR8.fullMode=false resolved all the proguard related issues (for now)

@angusryer
Copy link

angusryer commented Jan 18, 2024

Ran into this after upgrading to AGP 8 recently; my guess is that (in my case) this is appearing now due to R8 fullMode being enabled by default. https://r8.googlesource.com/r8/+/refs/heads/master/compatibility-faq.md#r8-full-mode has more details

It says we have to enable R8's fullMode manually with android.enableR8.fullMode=true in gradle.properties. The first paragraph states that they leave fullMode off by default to ease the migration from ProGuard to R8.

When upgrading from AGP 7.x to AGP 8.x (which is the update I just did when I encountered this), the docs here say the new default value is true https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes#default-changes

In my case, setting android.enableR8.fullMode=false resolved all the proguard related issues (for now)

That's great--thanks for clarifying! I'll see if this change resolves the error for me.

EDIT: It worked. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code
Projects
None yet
Development

No branches or pull requests

5 participants