1 <!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2 <html> 3 <head> 4 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> 5 <meta http-equiv="content-style-type" content="text/css"> 6 <link rel="stylesheet" type="text/css" href="style.css"> 7 <title>ProGuard Troubleshooting</title> 8 <script type="text/javascript" language="JavaScript"> 9 <!-- 10 if (window.self==window.top) 11 window.top.location.replace("../index.html#"+window.location.pathname+window.location.hash); 12 else { 13 var hash="#"+window.location.pathname.replace(window.top.location.pathname.replace("index.html", ""), ""); 14 if (window.top.location.hash!=hash) 15 window.top.location.hash=hash; 16 } 17 //--> 18 </script> 19 </head> 20 <body> 21 22 <h2>Troubleshooting</h2> 23 24 While preparing a configuration for processing your code, you may bump into a 25 few problems. The following sections discuss some common issues and solutions: 26 27 <h3><a href="#processing">Problems while processing</a></h3> 28 <ul> 29 <li><a href="#dynamicalclass">Note: can't find dynamically referenced class</a></li> 30 <li><a href="#dynamicalclasscast">Note: ... calls '(...)Class.forName(variable).newInstance()'</a></li> 31 <li><a href="#dynamicalclassmember">Note: ... accesses a field/method '...' dynamically</a></li> 32 <li><a href="#descriptorclass">Note: the configuration keeps the entry point '...', but not the descriptor class '...'</a></li> 33 <li><a href="#classmembers">Note: the configuration doesn't specify which class members to keep for class '...'</a></li> 34 <li><a href="#duplicateclass">Note: duplicate definition of program/library class</a></li> 35 <li><a href="#duplicatezipentry">Warning: can't write resource ... Duplicate zip entry</a></li> 36 <li><a href="#unresolvedclass">Warning: can't find superclass or interface</a></li> 37 <li><a href="#unresolvedclass">Warning: can't find referenced class</a></li> 38 <li><a href="#superclass">Error: Can't find any super classes of ... (not even immediate super class ...)</a></li> 39 <li><a href="#superclass">Error: Can't find common super class of ... and ...</a></li> 40 <li><a href="#unresolvedclassmember">Warning: can't find referenced field/method</a></li> 41 <li><a href="#unresolvedenclosingmethod">Warning: can't find enclosing class/method</a></li> 42 <li><a href="#dependency">Warning: library class ... depends on program class ...</a></li> 43 <li><a href="#unexpectedclass">Warning: class file ... unexpectedly contains class ...</a></li> 44 <li><a href="#mappingconflict1">Warning: ... is not being kept as ..., but remapped to ...</a></li> 45 <li><a href="#mappingconflict2">Warning: field/method ... can't be mapped to ...</a></li> 46 <li><a href="#unsupportedclassversion">Error: Unsupported class version number</a></li> 47 <li><a href="#keep">Error: You have to specify '-keep' options</a></li> 48 <li><a href="#filename">Error: Expecting class path separator ';' before 'Files\Java\...' (in Windows)</a></li> 49 <li><a href="#macosx">Error: Can't read [.../lib/rt.jar] (No such file or directory) (in MacOS X)</a></li> 50 <li><a href="#startinggui">Internal problem starting the ProGuard GUI (Cannot write XdndAware property) (in Linux)</a></li> 51 <li><a href="#outofmemoryerror">OutOfMemoryError</a></li> 52 <li><a href="#stackoverflowerror">StackOverflowError</a></li> 53 <li><a href="#unexpectederror">Unexpected error</a></li> 54 <li><a href="#otherwise">Otherwise...</a></li> 55 </ul> 56 57 <h3><a href="#afterprocessing">Unexpected observations after processing</a></h3> 58 <ul> 59 <li><a href="#disappearingclasses">Disappearing classes</a></li> 60 <li><a href="#notkept">Classes or class members not being kept</a></li> 61 <li><a href="#notobfuscated">Variable names not being obfuscated</a></li> 62 </ul> 63 64 <h3><a href="#dalvik">Problems while converting to Android Dalvik bytecode</a></h3> 65 66 <ul> 67 <li><a href="#simexception">SimException: local variable type mismatch</a></li> 68 <li><a href="#conversionerror">Conversion to Dalvik format failed with error 1</a></li> 69 </ul> 70 71 <h3><a href="#preverifying">Problems while preverifying for Java Micro Edition</a></h3> 72 73 <ul> 74 <li><a href="#invalidclassexception1">InvalidClassException, class loading error, or verification error</a></li> 75 </ul> 76 77 <h3><a href="#runtime">Problems at run-time</a></h3> 78 <ul> 79 <li><a href="#stacktraces">Stack traces without class names or line numbers</a></li> 80 <li><a href="#noclassdeffounderror">NoClassDefFoundError</a></li> 81 <li><a href="#classnotfoundexception">ClassNotFoundException</a></li> 82 <li><a href="#nosuchmethodexception">NoSuchMethodException</a></li> 83 <li><a href="#missingresourceexception">MissingResourceException or NullPointerException</a></li> 84 <li><a href="#disappearingannotations">Disappearing annotations</a></li> 85 <li><a href="#invalidjarfile">Invalid or corrupt jarfile</a></li> 86 <li><a href="#invalidjarindexexception">InvalidJarIndexException: Invalid index</a></li> 87 <li><a href="#invalidclassexception2">InvalidClassException, class loading error, or verification error (in Java Micro Edition)</a></li> 88 <li><a href="#nosuchfieldormethod">Error: No Such Field or Method, Error verifying method (in a Java Micro Edition emulator)</a></li> 89 <li><a href="#failingmidlets">Failing midlets (on a Java Micro Edition device)</a></li> 90 <li><a href="#disappearingloops">Disappearing loops</a></li> 91 <li><a href="#securityexception">SecurityException: SHA1 digest error</a></li> 92 <li><a href="#classcastexception">ClassCastException: class not an enum</a></li><li><a href="#classcastexception">IllegalArgumentException: class not an enum type</a></li> 93 <li><a href="#arraystoreexception">ArrayStoreException: sun.reflect.annotation.EnumConstantNotPresentExceptionProxy</a></li> 94 <li><a href="#compilererror">CompilerError: duplicate addition</a></li> 95 <li><a href="#classformaterror1">ClassFormatError: repetitive field name/signature</a></li> 96 <li><a href="#classformaterror2">ClassFormatError: Invalid index in LocalVariableTable in class file</a></li> 97 <li><a href="#nosuchmethoderror">NoSuchMethodError or AbstractMethodError</a></li> 98 <li><a href="#verifyerror">VerifyError</a></li> 99 </ul> 100 101 102 <h2><a name="processing">Problems while processing</a></h2> 103 104 ProGuard may print out some notes and non-fatal warnings: 105 106 <dl> 107 <dt><a name="dynamicalclass"><b>Note: can't find dynamically referenced class</b></a></dt> 108 109 <dd>ProGuard can't find a class or interface that your code is accessing by 110 means of introspection. You should check if you want to add the jar that 111 contains this class.</dd> 112 113 <dt><a name="dynamicalclasscast"><b>Note: ... calls '(...)Class.forName(variable).newInstance()'</b></a></dt> 114 115 <dd>ProGuard lists all class casts of dynamically created class instances, 116 like "<code>(MyClass)Class.forName(variable).newInstance()</code>". 117 Depending on your application, you may need to keep the mentioned classes 118 with an option like "<code>-keep class MyClass</code>", or their 119 implementations with an option like "<code>-keep class * implements 120 MyClass</code>". You can switch off these notes by specifying the 121 <a href="usage.html#dontnote"><code>-dontnote</code></a> option.</dd> 122 123 <dt><a name="dynamicalclassmember"><b>Note: ... accesses a field/method '...' dynamically</b></a></dt> 124 125 <dd>ProGuard lists a number of constructs like 126 "<code>.getField("myField")</code>". Depending on your application, you 127 may need to figure out where the mentioned class members are defined and 128 keep them with an option like "<code>-keep class MyClass { MyFieldType 129 myField; }</code>". Otherwise, ProGuard might remove or obfuscate the 130 class members, since it can't know which ones they are exactly. It does 131 list possible candidates, for your information. You can switch off these 132 notes by specifying the <a 133 href="usage.html#dontnote"><code>-dontnote</code></a> option.</dd> 134 135 <dt><a name="descriptorclass"><b>Note: the configuration keeps the entry point '...', but not the descriptor class '...'</b></a></dt> 136 137 <dd>Your configuration contains a <code>-keep</code> option to preserve the 138 given method (or field), but no <code>-keep</code> option for the given 139 class that is an argument type or return type in the method's descriptor. 140 You may then want to keep the class too. Otherwise, ProGuard will 141 obfuscate its name, thus changing the method's signature. The method might 142 then become unfindable as an entry point, e.g. if it is part of a public 143 API. You can switch off these notes by specifying the <a 144 href="usage.html#dontnote"><code>-dontnote</code></a> option.</dd> 145 146 <dt><a name="classmembers"><b>Note: the configuration doesn't specify which class members to keep for class '...'</b></a></dt> 147 148 <dd>Your configuration contains 149 a <code>-keepclassmembers/-keepclasseswithmembers</code> option to 150 preserve fields or methods in the given class, but it doesn't specify 151 which fields or methods. This way, the option simply won't have any 152 effect. You probably want to specify one or more fields or methods, as 153 usual between curly braces. You can specify all fields or methods with a 154 wildcard "<code>*;</code>". You can switch off these notes by specifying 155 the <a href="usage.html#dontnote"><code>-dontnote</code></a> option.</dd> 156 157 <dt><a name="duplicateclass"><b>Note: duplicate definition of program/library class</b></a></dt> 158 159 <dd>Your program jars or library jars contain multiple definitions of the 160 listed classes. ProGuard continues processing as usual, only considering 161 the first definitions. The warning may be an indication of some problem 162 though, so it's advisable to remove the duplicates. A convenient way to do 163 so is by specifying filters on the input jars or library jars. You can 164 switch off these notes by specifying the <a 165 href="usage.html#dontnote"><code>-dontnote</code></a> option.</dd> 166 167 <dt><a name="duplicatezipentry"><b>Warning: can't write resource ... Duplicate zip entry</b></a></dt> 168 169 <dd>Your input jars contain multiple resource files with the same name. 170 ProGuard continues copying the resource files as usual, skipping any files 171 with previously used names. Once more, the warning may be an indication of 172 some problem though, so it's advisable to remove the duplicates. A 173 convenient way to do so is by specifying filters on the input jars. There 174 is no option to switch off these warnings.</dd> 175 176 </dl> 177 <p> 178 179 ProGuard may terminate when it encounters parsing errors or I/O errors, or 180 some more serious warnings: 181 182 <dl> 183 <dt><a name="unresolvedclass"><b>Warning: can't find superclass or interface</b><br/><b>Warning: can't find referenced class</b></a></dt> 184 185 <dd>If there are unresolved references to classes or interfaces, you most 186 likely forgot to specify an essential library. For proper processing, all 187 libraries that are referenced by your code must be specified, including 188 the Java run-time library. For specifying libraries, use 189 the <a href="usage.html#libraryjars"><code>-libraryjars</code></a> option. 190 <p> 191 For example, if ProGuard complains that it can't find a 192 <code>javax.crypto</code> class, you probably still have to specify 193 <code>jce.jar</code>, next to the more common <code>rt.jar</code>. 194 <p> 195 If you're missing a library and you're absolutely sure it isn't used 196 anyway, you can try your luck with the <a 197 href="usage.html#ignorewarnings"><code>-ignorewarnings</code></a> option, 198 or even the <a href="usage.html#dontwarn"><code>-dontwarn</code></a> 199 option. Only use these options if you really know what you're doing 200 though. 201 <p> 202 For example, if you're developing for Android, and ProGuard complains that 203 it can't find a <code>java.awt</code> class, then some library that you 204 are using is referring to <code>java.awt</code>. This is a bit shady, since 205 Android doesn't have this package at all, but if your application works 206 anyway, you can let ProGuard accept it with "<code>-dontwarn 207 java.awt.**</code>".</dd> 208 209 <dt><a name="superclass"><b>Error: Can't find any super classes of ... (not even immediate super class ...)</b><br/><b>Error: Can't find common super class of ... and ...</b></a></dt> 210 211 <dd>It seems like you tried to avoid the warnings from the previous paragraph 212 by specifying 213 <a href="usage.html#ignorewarnings"><code>-ignorewarnings</code></a> 214 or <a href="usage.html#dontwarn"><code>-dontwarn</code></a>, but it didn't 215 work out. ProGuard's optimization step and preverification step really 216 need the missing classes to make sense of the code. Preferably, you would 217 solve the problem by adding the missing library, as discussed. If you're 218 sure the class that references the missing class isn't used either, you 219 could also try filtering it out from the input, by adding a filter to the 220 corresponding <a href="usage.html#injars"><code>-injars</code></a> option: 221 "<code>-injars 222 myapplication.jar(!somepackage/SomeUnusedClass.class)</code>". Hopefully, 223 you can access the configuration of your build process for such a 224 modification. As a final solution, you could switch off optimization 225 (<a href="usage.html#dontoptimize"><code>-dontoptimize</code></a>) and 226 preverification 227 (<a href="usage.html#dontpreverify"><code>-dontpreverify</code></a>).</dd> 228 229 <dt><a name="unresolvedclassmember"><b>Warning: can't find referenced field/method</b></a></dt> 230 231 <dd>If there are unresolved references to class members in input classes, your 232 class files are most likely inconsistent. Possibly, some class file didn't 233 get recompiled properly, or some class file was left behind after its 234 source file was removed. Try removing all class files, recompiling them, 235 zipping them up, and running ProGuard again. 236 <p> 237 If your program classes reside in the same packages as library classes, 238 and refer to their package visible class members, then you should also 239 specify the 240 <a href="usage.html#dontskipnonpubliclibraryclassmembers"><code>-dontskipnonpubliclibraryclassmembers</code></a> 241 option.</dd> 242 243 <dt><a name="unresolvedenclosingmethod"><b>Warning: can't find enclosing class/method</b></a></dt> 244 245 <dd>If there are unresolved references to classes that are defined inside 246 methods in your input, once more, your class files are most likely 247 inconsistent. Possibly, some class file didn't get recompiled properly, or 248 some class file was left behind after its source file was removed. Try 249 removing all class files, recompiling them, zipping them up, and running 250 ProGuard again.</dd> 251 252 <dt><a name="dependency"><b>Warning: library class ... depends on program class ...</b></a></dt> 253 254 <dd>If any of your library classes depend on your program classes, by 255 extending, implementing or just referencing them, your processed code will 256 generally be unusable. Program classes can depend on library classes, but 257 not the other way around. Program classes are processed, while library 258 classes always remain unchanged. It is therefore impossible to adapt 259 references from library classes to program classes, for instance if the 260 program classes are renamed. You should define a clean separation between 261 program code (specified with <a 262 href="usage.html#injars"><code>-injars</code></a>) and library code 263 (specified with <a 264 href="usage.html#libraryjars"><code>-libraryjars</code></a>), and try 265 again.</dd> 266 267 <dt><a name="unexpectedclass"><b>Warning: class file ... unexpectedly contains class ...</b></a></dt> 268 269 <dd>The given class file contains a definition for the given class, but the 270 directory name of the file doesn't correspond to the package name of the 271 class. ProGuard will accept the class definition, but the current 272 implementation will not write out the processed version. Please make sure 273 your input classes are packaged correctly. Notably, class files that are 274 in the <code>WEB-INF/classes</code> directory in a war should be packaged 275 in a jar and put in the <code>WEB-INF/lib</code> directory. If you don't 276 mind these classes not being written to the output, you can specify the <a 277 href="usage.html#ignorewarnings"><code>-ignorewarnings</code></a> option, 278 or even the <a href="usage.html#dontwarn"><code>-dontwarn</code></a> 279 option.</dd> 280 281 <dt><a name="mappingconflict1"><b>Warning: ... is not being kept as ..., but remapped to ...</b></a></dt> 282 283 <dd>There is a conflict between a <code>-keep</code> option in the 284 configuration, and the mapping file, in the obfuscation step. The given 285 class name or class member name can't be kept by its original name, as 286 specified in the configuration, but it has to be mapped to the other given 287 name, as specified in the mapping file. You should adapt your 288 configuration or your mapping file to remove the conflict. Alternatively, 289 if you're sure the renaming won't hurt, you can specify the <a 290 href="usage.html#ignorewarnings"><code>-ignorewarnings</code></a> option, 291 or even the <a href="usage.html#dontwarn"><code>-dontwarn</code></a> 292 option.</dd> 293 294 <dt><a name="mappingconflict2"><b>Warning: field/method ... can't be mapped to ...</b></a></dt> 295 296 <dd>There is a conflict between some new program code and the mapping file, in 297 the obfuscation step. The given class member can't be mapped to the given 298 name, because it would conflict with another class member that is already 299 being mapped to the same name. This can happen if you are performing 300 incremental obfuscation, applying an obfuscation mapping file from an 301 initial obfuscation step. For instance, some new class may have been added 302 that extends two existing classes, introducing a conflict in the name 303 space of its class members. If you're sure the class member receiving 304 another name than the one specified won't hurt, you can specify the <a 305 href="usage.html#ignorewarnings"><code>-ignorewarnings</code></a> option, 306 or even the <a href="usage.html#dontwarn"><code>-dontwarn</code></a> 307 option. Note that you should always use the <a 308 href="usage.html#useuniqueclassmembernames"><code>-useuniqueclassmembernames</code></a> 309 option in the initial obfuscation step, in order to reduce the risk of 310 conflicts.</dd> 311 312 <dt><a name="unsupportedclassversion"><b>Error: Unsupported class version number</b></a></dt> 313 314 <dd>You are trying to process class files compiled for a recent version of 315 Java that your copy of ProGuard doesn't support yet. You should check if 316 there is a more recent release 317 <a href="http://proguard.sourceforge.net/downloads.html">on-line</a>.</dd> 318 319 <dt><a name="keep"><b>Error: You have to specify '-keep' options</b></a></dt> 320 321 <dd>You either forgot to specify <a 322 href="usage.html#keep"><code>-keep</code></a> options, or you mistyped the 323 class names. ProGuard has to know exactly what you want to keep: an 324 application, an applet, a servlet, a midlet,..., or any combination of 325 these. Without the proper seed specifications, ProGuard would shrink, 326 optimize, or obfuscate all class files away.</dd> 327 328 <dt><a name="filename"><b>Error: Expecting class path separator ';' before 'Files\Java\</b>...<b>'</b> (in Windows)</a></dt> 329 330 <dd>If the path of your run-time jar contains spaces, like in "Program Files", 331 you have to enclose it with single or double quotes, as explained in the 332 section on <a href="usage.html#filename">file names</a>. This is actually 333 true for all file names containing special characters, on all 334 platforms.</dd> 335 336 <dt><a name="macosx"><b>Error: Can't read [</b>...<b>/lib/rt.jar] (No such file or directory)</b> (in MacOS X)</a></dt> 337 338 <dd>In MacOS X, the run-time classes may be in a different place than on most 339 other platforms. You'll then have to adapt your configuration, replacing 340 the path <code><java.home>/lib/rt.jar</code> by 341 <code><java.home>/../Classes/classes.jar</code>.</dd> 342 343 <dt><a name="startinggui"><b>Internal problem starting the ProGuard GUI (Cannot write XdndAware property)</b> (in Linux)</a></dt> 344 345 <dd>In Linux, at least with Java 6, the GUI may not start properly, due to 346 <a href="http://bugs.sun.com/view_bug.do?bug_id=7027598">Sun 347 Bug #7027598</a>. The work-around at this time is to specify the JVM 348 option <code>-DsuppressSwingDropSupport=true</code> when running the 349 GUI.</dd> 350 351 <dd> 352 353 </dl> 354 <p> 355 356 Should ProGuard crash while processing your application: 357 358 <dl> 359 <dt><a name="outofmemoryerror"><b>OutOfMemoryError</b></a></dt> 360 361 <dd>You can try increasing the heap size of the Java virtual machine (with the 362 usual <code>-Xms</code> and <code>-Xmx</code> options). You can also 363 reduce the amount of memory that ProGuard needs by removing unnecessary 364 library jars from your configuration, or by filtering out unused library 365 packages and classes. Remember that only classes or interfaces that are 366 extended or implemented by classes in your input jars are required.</dd> 367 368 <dt><a name="stackoverflowerror"><b>StackOverflowError</b></a></dt> 369 370 <dd>This error might occur when processing a large code base on Windows 371 (surprisingly, not so easily on Linux). In theory, increasing the stack 372 size of the Java virtual machine (with the usual <code>-Xss</code> option) 373 should help too. In practice however, the <code>-Xss</code> setting 374 doesn't have any effect on the main thread, due to <a 375 href="http://bugs.sun.com/view_bug.do?bug_id=4362291">Sun Bug 376 #4362291</a>. As a result, this solution will only work when running 377 ProGuard in a different thread, e.g. from its GUI.</dd> 378 379 <dt><a name="unexpectederror"><b>Unexpected error</b></a></dt> 380 381 <dd>ProGuard has encountered an unexpected condition, typically in the 382 optimization step. It may or may not recover. You should be able to avoid 383 it using the <a 384 href="usage.html#dontoptimize"><code>-dontoptimize</code></a> option. In 385 any case, please report the problem, preferably with the simplest example 386 that causes ProGuard to crash.</dd> 387 388 <dt><a name="otherwise"><b>Otherwise...</b></a></dt> 389 390 <dd>Maybe your class files are corrupt. See if recompiling them and trying 391 again helps. If not, please report the problem, preferably with the 392 simplest example that causes ProGuard to crash.</dd> 393 394 </dl> 395 <p> 396 397 <h2><a name="afterprocessing">Unexpected observations after processing</a></h2> 398 399 If ProGuard seems to run fine, but your processed code doesn't look right, 400 there might be a couple of reasons: 401 402 <dl> 403 <dt><a name="disappearingclasses"><b>Disappearing classes</b></a></dt> 404 405 <dd>If you are working on Windows and it looks like some classes have 406 disappeared from your output, you should make sure you're not writing your 407 output class files to a directory (or unpacking the output jar). On 408 platforms with case-insensitive file systems, such as Windows, unpacking 409 tools often let class files with similar lower-case and upper-case names 410 overwrite each other. If you really can't switch to a different operating 411 system, you could consider using ProGuard's <a 412 href="usage.html#dontusemixedcaseclassnames"><code>-dontusemixedcaseclassnames</code></a> 413 option. 414 <p> 415 Also, you should make sure your class files are in directories that 416 correspond to their package names. ProGuard will read misplaced class 417 files, but it will currently not write their processed versions. Notably, 418 class files that are in the <code>WEB-INF/classes</code> directory in a 419 war should be packaged in a jar and put in the <code>WEB-INF/lib</code> 420 directory.</dd> 421 422 <dt><a name="notkept"><b>Classes or class members not being kept</b></a></dt> 423 424 <dd>If ProGuard is not keeping the right classes or class members, make sure 425 you are using fully qualified class names. If the package name of some 426 class is missing, ProGuard won't match the elements that you might be 427 expecting. It may help to double-check for typos too. You can use the <a 428 href="usage.html#printseeds"><code>-printseeds</code></a> option to see 429 which elements are being kept exactly. 430 <p> 431 If you are using marker interfaces to keep other classes, the marker 432 interfaces themselves are probably being removed in the shrinking step. 433 You should therefore always explicitly keep any marker interfaces, with 434 an option like "<code>-keep interface MyMarkerInterface</code>". 435 <p> 436 Similarly, if you are keeping classes based on annotations, you may have to 437 avoid that the annotation classes themselves are removed in the shrinking 438 step. You can explicitly keep all annotation classes in your program code 439 with an option like "<code>-keep @interface *</code>".<dd> 440 441 <dt><a name="notobfuscated"><b>Variable names not being obfuscated</b></a></dt> 442 443 <dd>If the names of the local variables and parameters in your obfuscated code 444 don't look obfuscated, because they suspiciously resemble the names of 445 their types, it's probably because the decompiler that you are using is 446 coming up with those names. ProGuard's obfuscation step does remove the 447 original names entirely, unless you explicitly keep the 448 <code>LocalVariableTable</code> or <code>LocalVariableTypeTable</code> 449 attributes.</dd> 450 451 </dl> 452 453 <h2><a name="dalvik">Problems while converting to Android Dalvik bytecode</a></h2> 454 455 If ProGuard seems to run fine, but the dx tool in the Android SDK subsequently 456 fails with an error: 457 458 <dl> 459 <dt><a name="simexception"><b>SimException: local variable type mismatch</b></a></dt> 460 461 <dd>This error indicates that ProGuard's optimization step has not been able 462 to maintain the correct debug information about local variables. This can 463 happen if some code is optimized radically. Possible work-arounds: let the 464 java compiler not produce debug information (<code>-g:none</code>), or let 465 ProGuard's obfuscation step remove the debug information again 466 (by <i>not</i> keeping the attributes <code>LocalVariableTable</code> 467 and <code>LocalVariableTypeTable</code> 468 with <a href="usage.html#keepattributes"><code>-keepattributes</code></a>), 469 or otherwise just disable optimization 470 (<a href="usage.html#dontoptimize"><code>-dontoptimize</code></a>).</dd> 471 472 <dt><a name="conversionerror"><b>Conversion to Dalvik format failed with error 1</b></a></dt> 473 474 <dd>This error may have various causes, but if dx is tripping over some code 475 processed by ProGuard, you should make sure that you are using the latest 476 version of ProGuard. You can just copy the ProGuard jars 477 to <code>android-sdk/tools/proguard/lib</code>. If that doesn't help, 478 please report the problem, preferably with the simplest example that still 479 brings out the error.</dd> 480 481 </dl> 482 483 <h2><a name="preverifying">Problems while preverifying for Java Micro Edition</a></h2> 484 485 If ProGuard seems to run fine, but the external preverifier subsequently 486 produces errors, it's usually for a single reason: 487 488 <dl> 489 <dt><a name="invalidclassexception1"><b>InvalidClassException</b>, <b>class loading error</b>, or <b>verification error</b></a></dt> 490 491 <dd>If you get any such message from the preverifier, you are probably working 492 on a platform with a case-insensitive file system, such as Windows. The 493 <code>preverify</code> tool always unpacks the jars, so class files with 494 similar lower-case and upper-case names overwrite each other. You can use 495 ProGuard's <a 496 href="usage.html#dontusemixedcaseclassnames"><code>-dontusemixedcaseclassnames</code></a> 497 option to work around this problem. 498 <p> 499 If the above doesn't help, there is probably a bug in the optimization 500 step of ProGuard. Make sure you are using the latest version. You should 501 be able to work around the problem by using the <a 502 href="usage.html#dontoptimize"><code>-dontoptimize</code></a> option. You 503 can check the bug database to see if it is a known problem (often with a 504 fix). Otherwise, please report it, preferably with the simplest example on 505 which you can find ProGuard to fail.</dd> 506 507 </dl> 508 509 Note that it is no longer necessary to use an external preverifier. With the 510 <a href="usage.html#microedition"><code>-microedition</code></a> option, 511 ProGuard will preverify the class files for Java Micro Edition. 512 <p> 513 514 <h2><a name="runtime">Problems at run-time</a></h2> 515 516 If ProGuard runs fine, but your processed application doesn't work, there 517 might be several reasons: 518 519 <dl> 520 <dt><a name="stacktraces"><b>Stack traces without class names or line numbers</b></a></dt> 521 522 <dd>If your stack traces don't contain any class names or lines numbers, 523 even though you are keeping the proper attributes, make sure this debugging 524 information is present in your compiled code to start with. Notably the Ant 525 javac task has debugging information switched off by default.</dd> 526 527 <dt><a name="noclassdeffounderror"><b>NoClassDefFoundError</b></a></dt> 528 529 <dd>Your class path is probably incorrect. It should at least contain all 530 library jars and, of course, your processed program jar.</dd> 531 532 <dt><a name="classnotfoundexception"><b>ClassNotFoundException</b></a></dt> 533 534 <dd>Your code is probably calling <code>Class.forName</code>, trying to create 535 the missing class dynamically. ProGuard can only detect constant name 536 arguments, like <code>Class.forName("mypackage.MyClass")</code>. For 537 variable name arguments like <code>Class.forName(someClass)</code>, you 538 have to keep all possible classes using the appropriate <a 539 href="usage.html#keep"><code>-keep</code></a> option, e.g. "<code>-keep 540 class mypackage.MyClass</code>" or "<code>-keep class * implements 541 mypackage.MyInterface</code>".</dd> 542 543 <dt><a name="nosuchmethodexception"><b>NoSuchMethodException</b></a></dt> 544 545 <dd>Your code is probably calling something like 546 <code>myClass.getMethod</code>, trying to find some method dynamically. 547 Since ProGuard can't always detect this automatically, you have to keep 548 the missing method in using the appropriate <a 549 href="usage.html#keep"><code>-keep</code></a> option, e.g. "<code>-keep 550 class mypackage.MyClass { void myMethod(); }</code>". 551 <p> 552 More specifically, if the method reported as missing is 553 <code>values</code> or <code>valueOf</code>, you probably have to keep 554 some methods related to <a 555 href="examples.html#enumerations">enumerations</a>.</dd> 556 557 <dt><a name="missingresourceexception"><b>MissingResourceException</b> or <b>NullPointerException</b></a></dt> 558 559 <dd>Your processed code may be unable to find some resource files. ProGuard 560 simply copies resource files over from the input jars to the output jars. 561 Their names and contents remain unchanged, unless you specify the options 562 <a 563 href="usage.html#adaptresourcefilenames"><code>-adaptresourcefilenames</code></a> 564 and/or <a 565 href="usage.html#adaptresourcefilecontents"><code>-adaptresourcefilecontents</code></a>. 566 <p> 567 Furthermore, directory entries in jar files aren't copied, unless you 568 specify the option <a 569 href="usage.html#keepdirectories"><code>-keepdirectories</code></a>. 570 Note that Sun advises against calling <code>Class.getResource()</code> for 571 directories (<a href="http://bugs.sun.com/view_bug.do?bug_id=4761949">Sun 572 Bug #4761949</a>).</dd> 573 574 <dt><a name="disappearingannotations"><b>Disappearing annotations</b></a></dt> 575 576 <dd>By default, the obfuscation step removes all annotations. If your 577 application relies on annotations to function properly, you should 578 explicitly keep them with 579 <code><a href="usage.html#keepattributes">-keepattributes</a> 580 *Annotation*</code>.</dd> 581 582 <dt><a name="invalidjarfile"><b>Invalid or corrupt jarfile</b></a></dt> 583 584 <dd>You are probably starting your application with the java option 585 <code>-jar</code> instead of the option <code>-classpath</code>. The java 586 virtual machine returns with this error message if your jar doesn't 587 contain a manifest file (<code>META-INF/MANIFEST.MF</code>), if the 588 manifest file doesn't specify a main class (<code>Main-Class:</code> ...), 589 or if the jar doesn't contain this main class. You should then make sure 590 that the input jar contains a valid manifest file to start with, that this 591 manifest file is the one that is copied (the first manifest file that is 592 encountered), and that the main class is kept in your configuration,</dd> 593 594 <dt><a name="invalidjarindexexception"><b>InvalidJarIndexException: Invalid index</b></a></dt> 595 596 <dd>At least one of your processed jar files contains an index file 597 <code>META-INF/INDEX.LIST</code>, listing all class files in the jar. 598 ProGuard by default copies files like these unchanged. ProGuard may however 599 remove or rename classes, thus invalidating the file. You should filter the 600 index file out of the input 601 (<code>-injars in.jar(!META-INF/INDEX.LIST)</code>) or update the file 602 after having applied ProGuard (<code>jar -i out.jar</code>). 603 </dd> 604 605 <dt><a name="invalidclassexception2"><b>InvalidClassException</b>, <b>class loading error</b>, or <b>verification error</b> (in Java Micro Edition)</a></dt> 606 607 <dd>If you get such an error in Java Micro Edition, you may have forgotten to 608 specify the <a 609 href="usage.html#microedition"><code>-microedition</code></a> option, so 610 the processed class files are preverified properly.</dd> 611 612 <dt><a name="nosuchfieldormethod"><b>Error: No Such Field or Method</b>, <b>Error verifying method</b> (in a Java Micro Edition emulator)</a></dt> 613 614 <dd>If you get such a message in a Motorola or Sony Ericsson phone emulator, 615 it's because these emulators don't like packageless classes and/or 616 overloaded fields and methods. You can work around it by not using the 617 options <code><a href="usage.html#repackageclasses">-repackageclasses</a> 618 ''</code> and <a 619 href="usage.html#overloadaggressively"><code>-overloadaggressively</code></a>. 620 If you're using the JME WTK plugin, you can adapt the configuration 621 <code>proguard/wtk/default.pro</code> that's inside the 622 <code>proguard.jar</code>.</dd> 623 624 <dt><a name="failingmidlets"><b>Failing midlets</b> (on a Java Micro Edition device)</a></dt> 625 626 <dd>If your midlet runs in an emulator and on some devices, but not on some 627 other devices, this is probably due to a bug in the latter devices. For 628 some older Motorola and Nokia phones, you might try specifying the <a 629 href="usage.html#useuniqueclassmembernames"><code>-useuniqueclassmembernames</code></a> 630 option. It avoids overloading class member names, which triggers a bug in 631 their java virtual machine. 632 <p> 633 You might also try using the <a 634 href="usage.html#dontusemixedcaseclassnames"><code>-dontusemixedcaseclassnames</code></a> 635 option. Even if the midlet has been properly processed and then 636 preverified on a case-sensitive file system, the device itself might not 637 like the mixed-case class names. Notably, the Nokia N-Gage emulator works 638 fine, but the actual device seems to exhibit this problem.</dd> 639 640 <dt><a name="disappearingloops"><b>Disappearing loops</b></a></dt> 641 642 <dd>If your code contains empty busy-waiting loops, ProGuard's optimization 643 step may remove them. More specifically, this happens if a loop 644 continuously checks the value of a non-volatile field that is changed in a 645 different thread. The specifications of the Java Virtual Machine require 646 that you always mark fields that are accessed across different threads 647 without further synchronization as <code>volatile</code>. If this is not 648 possible for some reason, you'll have to switch off optimization using the 649 <a href="usage.html#dontoptimize"><code>-dontoptimize</code></a> 650 option.</dd> 651 652 <dt><a name="securityexception"><b>SecurityException: SHA1 digest error</b></a></dt> 653 654 <dd>You may have forgotten to sign your program jar <i>after</i> having 655 processed it with ProGuard.</dd> 656 657 <dt><a name="classcastexception"><b>ClassCastException: class not an enum</b>, or <br /><b>IllegalArgumentException: class not an enum type</b></a></dt> 658 659 <dd>You should make sure you're preserving the special methods of enumeration 660 types, which the run-time environment calls by introspection. The required 661 options are shown in the <a 662 href="examples.html#enumerations">examples</a>.</dd> 663 664 <dt><a name="arraystoreexception"><b>ArrayStoreException: sun.reflect.annotation.EnumConstantNotPresentExceptionProxy</b></a></dt> 665 666 <dd>You are probably processing annotations involving enumerations. Again, you 667 should make sure you're preserving the special methods of the enumeration 668 type, as shown in the examples.</dd> 669 670 <dt><a name="compilererror"><b>CompilerError: duplicate addition</b></a></dt> 671 672 <dd>You are probably compiling or running some code that has been obfuscated 673 with the <a 674 href="usage.html#overloadaggressively"><code>-overloadaggressively</code></a> 675 option. This option triggers a bug in 676 <code>sun.tools.java.MethodSet.add</code> in Sun's JDK 1.2.2, which is 677 used for (dynamic) compilation. You should then avoid this option.</dd> 678 679 <dt><a name="classformaterror1"><b>ClassFormatError: repetitive field name/signature</b></a></dt> 680 681 <dd>You are probably processing some code that has been obfuscated before with 682 the <a 683 href="usage.html#overloadaggressively"><code>-overloadaggressively</code></a> 684 option. You should then use the same option again in the second processing 685 round.</dd> 686 687 <dt><a name="classformaterror2"><b>ClassFormatError: Invalid index in LocalVariableTable in class file</b></a></dt> 688 689 <dd>If you are keeping the <code>LocalVariableTable</code> or 690 <code>LocalVariableTypeTable</code> attributes, ProGuard's optimizing step 691 is sometimes unable to update them consistently. You should then let the 692 obfuscation step remove these attributes or disable the optimization 693 step.</dd> 694 695 <dt><a name="nosuchmethoderror"><b>NoSuchMethodError</b> or <b>AbstractMethodError</b></a></dt> 696 697 <dd>You should make sure you're not writing your output class files to a 698 directory on a platform with a case-insensitive file system, such as 699 Windows. Please refer to the section about <a 700 href="#disappearingclasses">disappearing classes</a> for details. 701 <p> 702 Furthermore, you should check whether you have specified your program jars 703 and library jars properly. Program classes can refer to library classes, 704 but not the other way around. 705 <p> 706 If all of this seems ok, perhaps there's a bug in ProGuard (gasp!). If so, 707 please report it, preferably with the simplest example on which you can 708 find ProGuard to fail.</dd> 709 710 <dt><a name="verifyerror"><b>VerifyError</b></a></dt> 711 712 <dd>Verification errors when executing a program are almost certainly the 713 result of a bug in the optimization step of ProGuard. Make sure you are 714 using the latest version. You should be able to work around the problem by 715 using the <a href="usage.html#dontoptimize"><code>-dontoptimize</code></a> 716 option. You can check the bug database to see if it is a known problem 717 (often with a fix). Otherwise, please report it, preferably with the 718 simplest example on which ProGuard fails.</dd> 719 720 </dl> 721 722 <hr /> 723 <noscript><div><a target="_top" href="../index.html" class="button">Show menu</a></div></noscript> 724 <address> 725 Copyright © 2002-2011 726 <a target="other" href="http://www.lafortune.eu/">Eric Lafortune</a>. 727 </address> 728 </body> 729 </html> 730