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.

Klaxon throws exceptions after minifying (w/ Proguard)

See original GitHub issue

When Klaxon class names were minified, it could not find the DefaultConverter’s method toJson().

After adding the following rules to ProGuard, it throws a different exception:

-keep public class kotlin.reflect.jvm.internal.impl.** { public *; }
-keep class com.beust.klaxon.** { *; }
-keep interface com.beust.klaxon.** { *; }
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bleh.application/com.bleh.application.WhateverActivity}: java.lang.ClassCastException: java.lang.String cannot be cast to com.beust.klaxon.JsonObject

The application works perfectly when I turn minify off. Any ideas?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
spreelankacommented, Jul 30, 2019

@Tarpsvo try adding

-keep class kotlin.Metadata { *; }

this is what worked with minify for my project:

# Klaxon
-keep public class kotlin.reflect.jvm.internal.impl.** { public *; }
-keep class com.beust.klaxon.** { *; }
-keep interface com.beust.klaxon.** { *; }
-keep class kotlin.Metadata { *; }

#data models
-keep class com.example.mydatamodels.** { *;}
1reaction
cbeustcommented, Jul 30, 2019

Note that the error might be coming from a converter outside of the com.beust.klaxon package. If you wrote any custom converter, make sure to keep these classes too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Klaxon throws exceptions after minifying (w/ Proguard) -
Klaxon throws exceptions after minifying (w/ Proguard) ... When Klaxon class names were minified, it could not find the DefaultConverter's method toJson() ....
Read more >
Obfuscating method with throws clause - java - Stack Overflow
I'm using ProGuard to obfuscate my code. My project is comprised of a few modules, each obfuscated independently. ... The library with the...
Read more >
Troubleshooting ProGuard issues on Android - Medium
Getting a ClassNotFoundException or MethodNotFoundException at runtime is a sure sign you are missing classes or methods, either because ...
Read more >
Wall Avenue Protests, Facebook, Twitter, Lookup, Youtube ...
Wall Street Protests, Facebook, Twitter, Search, Youtube, Videos, Craigslist, Cnn, News, Photos, Pictures, Movies, Moammar Kadafi, Dead, ...
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