MartinVonMartinsgrün MartinVonMartinsgrün - 1 year ago 130
Android Question

Proguard "Missing type parameter" on Samsung device

I`ve published an android app, obfuscated by dexguard. Everything seems to be fine, except for the Galaxy Tab 3 10.1 and only with Android 4.4, which is the only device, that reports errors to the developer console.

I get following exception:

java.lang.RuntimeException: Missing type parameter.
at com....util.Helper$2.<init>(:398)

Code in class and line 398

return (Config) getSerializable(context, CONFIG, new TypeToken<Config>(){}.getType());

My dexguard rules:

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }

# Application classes that will be serialized/deserialized over Gson
# path to the config class: com/.../models/config/;
-keep class com....models.** { *; }

-keepattributes Signature

Not only that I can not reproduce the error myself (i also have an Galaxy Tab 3 with Android 4.2, update not available yet), it only concerns the above mentioned device.

Answer Source

My solution was to avoid the use of the TypeToken and updating dexguard to the latest version.

For example:

Instead of

new Gson().fromJson(json, new TypeToken<Object>(){}.getType());

use this

new Gson().fromJson(json, Object.class);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download