Build failed with mozilla rhino dependency

Hi! I try to build our application with mozilla rhino dependency

compile group: 'org.mozilla', name: 'rhino', version: '1.7.7.1'

I think problem is here:

dex2oat F 57679 2494359 /Volumes/SSD/gh-moe-master/aosp/art/compiler/oat_writer.cc:645]Unexpected failure to resolve a method: 
void org.mozilla.javascript.tools.debugger.ContextWindow$1.<init>(org.mozilla.javascript.tools.debugger.ContextWindow, javax.swing.JPanel, javax.swing.JToolBar, javax.swing.JPanel, org.mozilla.javascript.tools.debugger.SwingGui, javax.swing.JToolBar, javax.swing.JPanel, javax.swing.JSplitPane)dex2oat F 57679 2494359 /Volumes/SSD/gh-moe-master/aosp/art/compiler/oat_writer.cc:650] java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

I dont use these javax.swing.* /org.mozilla.javascript.tools.debugger.* classes in my app.
So, how can I avoid that problems?

Dear zufarfakhurtdinov,

this may come from Rhino having a static void main(String[]) method in one of its classes. In the default proguard configuration file there is the following rule which would cause it to be kept:

-keepclasseswithmembers public class * {
    public static void main(java.lang.String[]);
}

If Rhino’s main method even indirectly references these swing classes, then because of this rule, ProGuard will try to keep it.

To work around this issue, do the following:

  • Copy the ~/.moe/moe-sdk-1.1.0/tools/proguard.cfg file into your MOE module’s directory (do not rename it to proguard.append.cfg)
  • Change the above rule from public class * to public class your.main.ClassName

This way only the main method of your class will be kept.

2 Likes