question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing type parameter RuntimeException

See original GitHub issue

Gson version

‘2.8.9’

Java / Android version

Java 11 / Android all

I’m facing following exception with Gradle version ‘7.1.0’, whereas ‘7.0.4’ is working fine. The issue is happening in both cases when minifyEnabled = true/false in that module, but main app module has minifyEnabled=true and proguard rules are mentioned as well.

Fatal Exception: java.lang.RuntimeException
Missing type parameter.
com.google.gson.reflect.TypeToken.getSuperclassTypeParameter (TypeToken.java:84)
com.google.gson.reflect.TypeToken.<init> (TypeToken.java:62)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
forlayocommented, Mar 2, 2022

In my case was just adding the following to proguard configuration:

# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken

Here you go the full set of options that are needed for Gson -> https://github.com/google/gson/blob/master/examples/android-proguard-example/proguard.cfg

3reactions
easyonebdcommented, Jun 6, 2022

if anyone has the same problem, didn’t gotten any solution yet, you can try this. I faced the same issue and adding these 3 lines in progurd saved my day.

-keep class com.google.gson.reflect.TypeToken
-keep class * extends com.google.gson.reflect.TypeToken
-keep public class * implements java.lang.reflect.Type
Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.RuntimeException: Missing type parameter [closed]
The class TypeToken requires a type parameter. Looking at your code, it looks like you should replace. Type listType = new TypeToken() {...
Read more >
TypeToken instantiation with generic list throwing ...
Using Gson 2.0, this code throws "java.lang.RuntimeException: Missing type parameter." on line [Type t = new TypeToken<List<String>>() {}.getType();]:.
Read more >
Android – proguard Missing type parameter – iTecNote
i try obfuscate my code of android app with ProGuard . But after this my app give exception at running: 11-15 01:46:26.818: W/System.err(21810):...
Read more >
Mobile-Xamarin App integrates with New Relic
agent.andriod.SaveState. Caused by java.lang.RuntimeException.Missing type parameter at com.newrelic.com.google.generateTypeToken at com ...
Read more >
android System.err: java.lang.RuntimeException: Missing type ...
DemoApp W/System.err: java.lang.RuntimeException: Missing type parameter. at bji.getSuperclassTypeParameter(Unknown Source) at com.example.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found