Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Proguard ignore external libraries?

I want to use Proguard mainly for obfuscation reasons.

My problem is that I have three libraries, Twitter4J and two signpost libraries. These libraries caused errors when I tried to create an signed APK. To get over this I put the following in the proguard.config file...

-dontwarn org.apache.commons.codec.binary.**  -dontwarn org.slf4j.**  -dontwarn com.sun.syndication.io.** -dontwarn com.sun.syndication.feed.synd.*    

While this got rid of the errors in the console, when i loaded my signed APK onto my mobile phone it instantly crashed. The DDMS said this was due to a class not found in Twitter4J.

Getting rid of the "dontwarns" above did not help. Neither did adding dontshrink dontoptimise.

I would like Proguard to completely ignore the libraries (as they are open source anyway). Is this possible?

like image 938
Mel Avatar asked Oct 11 '11 04:10

Mel


People also ask

What is ProGuard obfuscation?

ProGuard is a command-line tool that reduces app size by shrinking bytecode and obfuscates the names of classes, fields and methods. It's an ideal fit for developers working with Java or Kotlin who are primarily interested in an Android optimizer.

Does ProGuard obfuscate package name?

Obfuscating package names myapplication. MyMain is the main application class that is kept by the configuration. All other class names can be obfuscated. Note that not all levels of obfuscation of package names may be acceptable for all code.

Does ProGuard obfuscate code?

You can obfuscate Android code to provide security against reverse engineering. You can use the Android ProGuard tool to obfuscate, shrink, and optimize your code.


1 Answers

Try this:

-keep class javax.** { *; } -keep class org.** { *; } -keep class twitter4j.** { *; } 

Cf post from @CaspNZ: Android Proguard with external jar

like image 131
Murphy Avatar answered Sep 30 '22 08:09

Murphy