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.

Proguard Rules for Android

See original GitHub issue

Hi!

Thanks for the project, it’s amazing!

Nevertheless, whenever I try to use it in an Android project that also uses Proguard, the compiler says that some classes could not be found:

Warning:org.cache2k.core.util.Log: can't find referenced class org.slf4j.LoggerFactory
Warning:org.cache2k.core.util.Log: can't find referenced class org.slf4j.helpers.NOPLoggerFactory
Warning:org.cache2k.core.util.Log: can't find referenced class org.slf4j.LoggerFactory
Warning:org.cache2k.core.util.Log: can't find referenced class org.slf4j.ILoggerFactory
Warning:org.cache2k.core.util.Log$1: can't find referenced class org.slf4j.ILoggerFactory
Warning:org.cache2k.core.util.Log$Slf4jLogger: can't find referenced class org.slf4j.Logger
Warning:org.cache2k.core.util.ThreadDump: can't find referenced class java.lang.management.ManagementFactory
Warning:org.cache2k.core.util.ThreadDump: can't find referenced class java.lang.management.ThreadMXBean
Warning:org.cache2k.core.util.ThreadDump: can't find referenced class java.lang.management.ThreadInfo
Warning:org.cache2k.core.util.ThreadDump: can't find referenced class java.lang.management.ThreadMXBean
Warning:org.cache2k.core.util.ThreadDump: can't find referenced class java.lang.management.ThreadInfo
Warning:org.cache2k.core.util.ThreadDump: can't find referenced class java.lang.management.ManagementFactory
Warning:org.cache2k.core.util.ThreadDump: can't find referenced class java.lang.management.ThreadMXBean
Warning:org.cache2k.core.util.ThreadDump: can't find referenced class java.lang.management.ThreadInfo
Warning:org.cache2k.core.util.ThreadDump: can't find referenced class java.lang.management.ThreadMXBean
Warning:org.cache2k.core.util.ThreadDump: can't find referenced class java.lang.management.ThreadInfo

I have tried to add the following rules to avoid it:

-keep public class org.cache2k.core.util.**
-dontwarn org.slf4j**
-dontwarn java.lang.management**

But as soon as I launch the app with the rules, It crash because it can’t find some methods (they are obfuscated so it won’t call them)

What are the rules that must be used??

Thanks in advice!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cruftexcommented, Jul 3, 2018

There is a new release (1.1.1.Alpha) which comes with an example of ProGuard rules. The description is here: https://cache2k.org/docs/latest/user-guide.html#android The JUnit test is is in the module: https://github.com/cache2k/cache2k/tree/master/test-android-proguard

The versions 1.1.x are intended for development and to stabilize the new features. I plan to release 1.2 in a couple of weeks.

0reactions
rodrixancommented, Nov 20, 2017

That’s what I’m currently investigating, but for the moment I haven’t seen anything about “Avoid optimization for a specific class”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Shrink, obfuscate, and optimize your app - Android Developers
R8 uses ProGuard rules files to modify its default behavior and better understand your app's structure, such as the classes that serve as...
Read more >
Configuring ProGuard | CodePath Android Cliffnotes
ProGuard is a tool to help minify, obfuscate, and optimize your code. It is not only especially useful for reducing the overall size...
Read more >
Practical ProGuard rules examples | by Wojtek Kaliciński
Android's default ProGuard files (you should always include them, they have some really useful rules) already contain a rule for methods that ...
Read more >
ProGuard in Android - GeeksforGeeks
It shrinks the application's size. · It removes unused classes and methods that contribute to an Android application's 64K method count limit.
Read more >
ProGuard Manual: Usage - Guardsquare
For example, you can optimize your app for given Android SDK versions by specifying the supported range in the version constant. ProGuard can...
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