Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using "dontwarn" in proguard

I use proguard successfully but whenever I add external library (those that belongs to advertising) proguard fails with "can't find reference ...etc". I tried many combination such as libraryjars, injars ...etc but no luck.

Then I used the " -dontwarn " option on the external file and things worked magically. Is this bad to do? I mean is there a problem I am not seeing with handling external jars using this attribute?

Thank you

like image 572
Snake Avatar asked Sep 09 '13 08:09

Snake


People also ask

What is Dontwarn in ProGuard?

If your code works fine without the missing classes, you can suppress the warnings with '-dontwarn' options. ( http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)

Does ProGuard obfuscate XML?

ProGuard can't obfuscate strings. xml. You can use other software to obfuscate your file like DexGuard. You can get more info here.

Does ProGuard remove unused classes?

Shrinking Options By default, ProGuard shrinks the code: it removes all unused classes and class members.


1 Answers

For warnings about missing third-party classes, the options -ignorewarnings or -dontwarn are probably fine. If the code already works in debug mode, it means that the listed missing classes are never used. You can then tell ProGuard to proceed processing the code anyway.

For warnings about missing Android runtime classes, fields, or methods, you should build against a sufficiently recent Android runtime, specified in project.properties. You can still target an older Android runtime in AndroidManifest.xml.

See the ProGuard manual > Troubleshooting:

  • Warning: can't find referenced class
  • Warning: can't find referenced field/method '...' in library class ...

Note that you should not add -injars or -libraryjars options to your configuration, since the standard Ant/Eclipse/Gradle build processes automatically specify these for you.

like image 76
Eric Lafortune Avatar answered Oct 02 '22 19:10

Eric Lafortune