androidjvmdalvikdexdx

Stripping out AWT references from Android Dex file at compile time


I am getting warnings in my Android app saying that my bytecode makes illegal references to java.awt and in some cases the runtime seems to replace invalid opcodes.

09-22 19:36:41.688: W/dalvikvm(831): VFY: unable to find class referenced in signature (Ljava/awt/Component;)
09-22 19:36:41.688: W/dalvikvm(831): VFY: unable to resolve virtual method 523:   Ljava/awt/Component;.isLightweight ()Z
09-22 19:36:41.688: D/dalvikvm(831): VFY: replacing opcode 0x6e at 0x0000

Is there something I can do to tell the DX tool to clean out or replace these references earlier (like at compile time) so that the generated dex file no longer has those references?


Solution

  • You might try proguard. I don't know offhand if it can strip out unused methods inside a class, or if it only strips out entire classes. If it's the former, it will likely be able to get rid of the offending references. If it's the latter, probably not.

    But in any case, these are just warnings, and are mostly harmless. The only "harm" is that it adds a bit of bloat to your dex file, which requires a bit of extra memory/disk space.