Proguard - Can't find any super classes

纵饮孤独 提交于 2019-12-10 18:43:40

问题


I'm getting this error:

Unexpected error while performing partial evaluation:
Class       = [org/apache/log4j/chainsaw/Main]
Method      = [<init>()V]
Exception   = [java.lang.IllegalArgumentException] (Can't find any super classes of [org/apache/log4j/chainsaw/LoadXMLAction] (not even immediate super class [javax/swing/AbstractAction]))
Error: Can't find any super classes of [org/apache/log4j/chainsaw/LoadXMLAction] (not even immediate super class [javax/swing/AbstractAction])

Part of my proguard configuration:

-dontwarn javax.jms.**
-dontwarn com.sun.jdmk.comm.**
-dontwarn android.support.v4.**
-dontwarn com.google.api.client.googleapis.extensions.**
-dontwarn org.apache.harmony.**
-dontwarn com.sun.**
-dontwarn org.simpleframework.**
-dontwarn com.google.android.gms.**
-dontwarn org.apache.log4j.lf5.viewer.**
-dontwarn java.beans.**
-dontwarn org.apache.log4j.**

-libraryjars 'D:\Workspace\android\libs\acra-4.5.0.jar'
-libraryjars 'D:\Workspace\android\libs\activation.jar'
-libraryjars 'D:\Workspace\android\libs\additionnal.jar'
-libraryjars 'D:\Workspace\android\libs\android-logging-log4j-1.0.3.jar'
-libraryjars 'D:\Workspace\android\libs\android-support-v4.jar'
-libraryjars 'D:\Workspace\android\libs\annotations.jar'
-libraryjars 'D:\Workspace\android\libs\google-api-client-android-1.12.0-beta.jar'
-libraryjars 'D:\Workspace\android\libs\jtar-1.1.jar'
-libraryjars 'D:\Workspace\android\libs\log4j-1.2.15.jar'
-libraryjars 'D:\Workspace\android\libs\mail.jar'
-libraryjars 'D:\Workspace\android\libs\simple-xml-2.6.9.jar'

The library for log4j is there, so what could be the problem?

UPDATE

As I have found the problem is raised during optimalization. Shrink and obfuscation is working.


回答1:


For those who need a fast solution on using Log4J on Android, Krivers' update actually served as a hint: setting -dontoptimize in ProGuard configuration turns off optimization and thus avoids the error (although this should only be considered as a workaround).

In fact, the Android Tools Project Site had also suggested to turn off ProGuard optimization:

Dalvik performs many of its own optimizations, and some of the optimizations performed by ProGuard are incompatible with Dalvik, so to avoid hard-to-figure-out bugs (and because the net performance gain is usually small), the default configuration turns off optimization.




回答2:


The class org.apache.log4j.chainsaw.LoadXMLAction extends the class javax.swing.AbstractAction. This latter class is part of Swing, which is not present in Android. Therefore, LoadXMLAction can never be used in practice. Furthermore, ProGuard can't analyze this class properly without its complete class hierarchy.

Solution: you should avoid adding LoadXMLAction to your application libraries, either by not putting the corresponding Apache jar in your libs directory, or by filtering out the class (and similar classes) from the ProGuard injars options (more difficult in the standard build process), or by removing the class from the jar.



来源:https://stackoverflow.com/questions/16667022/proguard-cant-find-any-super-classes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!