(MyClass)Class.forName(variable).newInstance()
", ProGuard
will list them. Depending on your application, you may need to keep the
mentioned classes with an option like "-keep class MyClass
",
or their implementations with an option like "-keep class *
implements MyClass
". You can switch off these notes by specifying
the -dontnote
option.
ProGuard may terminate when it encounters parsing errors or I/O errors, or some more serious warnings:
-keep
options, you either forgot them or you mistyped the class names.
ProGuard has to know exactly what you want to keep: an application, an
applet, a servlet, a midlet,..., or any combination of these. Without the
proper seed specifications, ProGuard would mark all class files as unused,
and your output jar would be empty.
-libraryjars
option.
If the class that is reported as missing is a non-public library class,
you should specify the -dontskipnonpubliclibraryclasses
option. A common example is the class
java.util.zip.ZipConstants
, which is used as an interface
class in some public classes, even though it is only package visible (in
this case, the warning could also be ignored, because the class is not a
fundamental part of the class hierarchy).
If you're missing a library and you're absolutely sure it isn't used
anyway, you can try your luck with the -ignorewarnings
option, or even the -dontwarn
option.
Should ProGuard crash while processing your application:
OutOfMemoryError
, you can try increasing
the heap size of the Java virtual machine (with the usual
-Xms
and -Xmx
options). You can also reduce the
amount of memory that ProGuard needs by removing unnecessary library jars
from your configuration. Remember that only libraries containing classes
or interfaces that are extended or implemented by classes in your input
jars are required.
-printseeds
option to see which elements are being kept
exactly.
preverify
tool always unpacks the jars it processes. If you
really can't switch to a different operating system, you could consider
using ProGuard's -dontusemixedcaseclassnames
option.
NoClassDefFoundError
, your class path is
probably incorrect. It should at least contain all library jars and, of
course, your processed program jar.
ClassNotFoundException
, your code is
probably calling Class.forName
, trying to create the missing
class dynamically. ProGuard can only detect constant name arguments, like
Class.forName("mypackage.MyClass")
. For variable name
arguments like Class.forName(someClass)
, you have to keep all
possible classes using the -keep
option, e.g. "-keep
class mypackage.MyClass
" or "-keep class * implements
mypackage.MyInterface
".
NoSuchMethodException
, your code is
probably calling something like myClass.getMethod
, trying to
find some method dynamically. Since ProGuard isn't detecting this (yet),
you have to keep the missing method in using the -keep
option, e.g. "-keep class mypackage.MyClass { void myMethod();
}
".
NullPointerException
or if you don't see
any icons, your processed code may be unable to find some resource files.
ProGuard currently simply copies resource files over from the input jars
or, if specified, from the resource jars, to the output jar. Their names
and contents remain unchanged. If you've used the
-defaultpackage
option, the package names of some classes may
have changed, and along with them, the directory in which they look for
their resource files. It's better not to use this option in these
circumstances.
InvalidClassException
or a
verification error in J2ME, you may have forgotten to preverify
your program jar after having processed it with ProGuard.
NoSuchMethodError
or an
AbstractMethodError
, you should make sure you're not
writing your output class files to a directory (or unpacking the output
jar) on a platform with a case-insensitive file system, such as Windows.
Refer to the item about disappearing classes, higher up in this list, for
details.
Furthermore, you should check whether you have specified your program jars and library jars properly. Program classes can refer to library classes, but not the other way around.
If all of this seems ok, perhaps there's a bug in ProGuard (gasp!). If so, please report it, preferably with the simplest example on which you can find ProGuard to fail.