When I enabing proguard for android, the proguard will obfuscate all the jars that include in the application. These jars include:
while building the signed jar I get the following dump:
06-25 16:07:25.094: WARN/dalvikvm(13785): Exception Ljava/lang/NoSuchMethodError; own while initializing Lorg/apache/commons/httpclient/HttpMethodBase;
06-25 16:07:25.094: WARN/dalvikvm(13785): threadid=14: thread exiting with uncaught exception (group=0x40015560)
06-25 16:07:25.104: ERROR/AndroidRuntime(13785): FATAL EXCEPTION: Thread-18
06-25 16:07:25.104: ERROR/AndroidRuntime(13785): java.lang.ExceptionInInitializerError
06-25 16:07:25.104: ERROR/AndroidRuntime(13785): at weibo4andriod.http.HttpClient.a(Unknown Source)
06-25 16:07:25.104: ERROR/AndroidRuntime(13785): at weibo4andriod.Weibo.a(Unknown
Source)
06-25 16:07:25.104: ERROR/AndroidRuntime(13785): at com.snda.childbook.UpdateStatusThread.run(Unknown Source)
06-25 16:07:25.104: ERROR/AndroidRuntime(13785): at java.lang.Thread.run(Thread.java:1019)
06-25 16:07:25.104: ERROR/AndroidRuntime(13785): Caused by: java.lang.NoSuchMethodError: org.apache.commons.logging.LogFactory.c
06-25 16:07:25.104: ERROR/AndroidRuntime(13785): at org.apache.commons.httpclient.HttpMethodBase.<clinit>(Unknown Source)
06-25 16:07:25.104: ERROR/AndroidRuntime(13785): ... 4 more
06-25 16:07:25.104: WARN/ActivityManager(104): Force finishing activity com.snda.childbook/.BookReader
In fact this project is about sina weibo SDK, when I use proguard to obfuscate it, I always fail, with the error below:
testpostmethord] Proguard returned with error code 1. See console
[2011-06-27 15:31:11 - testpostmethord] Note: there were 1 duplicate class definitions.
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find superclass or interface javax.servlet.ServletContextListener
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.AvalonLogger: can't find referenced class org.apache.avalon.framework.logger.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Category
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Priority
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.Log4JLogger: can't find referenced class org.apache.log4j.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Hierarchy
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Hierarchy
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Hierarchy
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.LogKitLogger: can't find referenced class org.apache.log.Logger
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextListener
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextEvent
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextEvent
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextEvent
[2011-06-27 15:31:11 - testpostmethord] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find referenced class javax.servlet.ServletContextEvent
[2011-06-27 15:31:11 - testpostmethord] You should check if you need to specify additional program jars.
[2011-06-27 15:31:11 - testpostmethord] Warning: there were 70 unresolved references to classes or interfaces.
[2011-06-27 15:31:11 - testpostmethord] You may need to specify additional library jars (using '-libraryjars').
[2011-06-27 15:31:11 - testpostmethord] java.io.IOException: Please correct the above warnings first.
[2011-06-27 15:31:11 - testpostmethord] at proguard.Initializer.execute(Initializer.java:321)
[2011-06-27 15:31:11 - testpostmethord] at proguard.ProGuard.initialize(ProGuard.java:211)
[2011-06-27 15:31:11 - testpostmethord] at proguard.ProGuard.execute(ProGuard.java:86)
[2011-06-27 15:31:11 - testpostmethord] at proguard.ProGuard.main(ProGuard.java:492)
so I added the code -ignorewarnings into proguard config file, so the warnings all dismissed, but when I run the application, The errors that in the title will happened.
Ran into the same problem on an outsourced project where it seems the developers have used every possible free library in the world.
The safest approach is to supply ProGuard with the original libraries as a reference, even though some of them are deprecated and probably will never be called by your code:
Log4J - http://logging.apache.org/log4j/1.2/download.html
Avalon - http://www.docjar.com/jar_detail/avalon-framework-4.2.0.jar.html
Avalon LogKit - http://www.jarfinder.com/index.php/jars/versionInfo/17610
J2EE reference - http://www.jarfinder.com/index.php/jars/versionInfo/4598
Once you download all of the jars, point ProGuard to them:
# Apache commomns-logging fun
-libraryjars proguard_ref_lib/log4j-1.2.17.jar
-libraryjars proguard_ref_lib/avalon-framework-4.2.0.jar
-libraryjars proguard_ref_lib/avalon-logkit-2.2.1.jar
-libraryjars proguard_ref_lib/servlet-api-6.0.16.jar
# Apache commomns-logging fun ends
Enjoy