Android Studio Plugin Error: NoClassDefFoundError: javafx/embed/swing/JFXPanel

Hi,

I developed a plugin by using IntelliJ IDEA, and once I install it in Android Studio and I try to run it, it gives me the following error:

17:46 Plugin Error: TaskAnnotationPlugin threw an uncaught NoClassDefFoundError. Disable Plugin

17:46 NoClassDefFoundError: javafx/embed/swing/JFXPanel

Do you know how can I fix it, please??? Thank you!!

The details of the error are:

javafx/embed/swing/JFXPanel
java.lang.NoClassDefFoundError: javafx/embed/swing/JFXPanel
at main.PluginAction.actionPerformed(PluginAction.java:14)
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:197)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:156)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:211)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$2(ActionMenuItem.java:304)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:905)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:124)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:284)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:112)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
at com.intellij.openapi.application.TransactionGuardImpl.access$300(TransactionGuardImpl.java:40)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:113)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:123)
at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:109)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:112)
at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:513)
at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:45)
at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:533)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:795)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:627)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:387)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ClassNotFoundException: javafx.embed.swing.JFXPanel PluginClassLoader[TaskAnnotationPlugin, 1.0]
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:64)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 54 more

0

What JDK version do you use to run IntelliJ IDEA with this plug-in? Does your JDK distribution include JavaFX?

0

I am using 1.8.0_144

0

I installed it and once I run the plugin in IntellIJ IDEA is not working....., it gives me this error::

 

Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: org/abego/treelayout/Configuration
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.newInstance(Class.java:412)
at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:927)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at main.MainSwing.createScene(MainSwing.java:58)
at main.MainSwing.initFX(MainSwing.java:44)
at main.MainSwing.access$100(MainSwing.java:13)
at main.MainSwing$2.run(MainSwing.java:36)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.abego.treelayout.Configuration PluginClassLoader[TaskAnnotationPlugin, 1.0] com.intellij.ide.plugins.cl.PluginClassLoader@3907bfd5
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 24 more

0

IDE has to be started on the JDK that includes JavaFX.

0

this class that is not finding is from an external .jar that I added to the skd I was using,, but since I did what you told me, it gives me this error

0

Actually, the jdk I was using before was including JavaFX::

0

It includes JavaFX sources.

0

ups, sorry, this was the correct:

0

Which jar contains org/abego/treelayout/Configuration file? Did you include it into your plug-in distribution? This error is different from the one your posted in the original issue description.

0

The error of the original issue description is the one I get at the beginning, once I was running my plugin in Android Studio,,, but now, I did what you told me about installing the default JetBrains Runtime, and I cannot even run it in IntellIJ IDEA,, and gives me the last commented error. In fact, in order to run it having installed what you told me, I have to add a project library with the org/abego/treelayout, what is strange, because this .jar already is inside the project SKD defined when I started the project...

How can I revert what you told me to do? Because now I cannot even run it in IDEA, and before I was able to but not in Android Studio.

0

The library must be present in the plug-in distribution, not in the SDK, since other users will not have it present in their SDK, hence it must be a part of your plug-in. The first problem was caused by the missing JavaFX in the Java installation used to run the IDE on your system. This issue is solved by using JetBrains Runtime or by using the system JDK with JavaFX. Some Linux distributions do not have JavaFX installed by default.

0

Okey, then, I guess you advice me to add JavaFX library and other external libraries that my plugin uses (like org.abego.treelayout) to my plugin project (Project Structure -> Libraries) in order to, when a user installes it in his Android Studio, be properly working... right? Or, can it happen also that if fails in his Android Studio because he has not installed JavaFX in his jdk even my plugin contains it? I am running it on Windows..

And actually, JavaFX should be included in the 1.8.0_144 version of JDK/JRE.. (the one I am using)..


Sorry for asking you so much, but is the last part of my project and I have not so much time, and having so many troubles just for using it on Android Studio...

0

JavaFX is already included in the JDK that is bundled with IntelliJ IDEA and Android Studio. If the user uses default runtime, everything will work out of the box. You should not include JavaFX in your plug-in distribution, only other third-party libraries that are not part of the JDK/JavaFX.

0

Then, I don't understand what should I do... because the error that is giving me when I run it on Android Studio is because of JFX...  are there any requirements then that the user should have installed in his Android Studio or what should I do?

0

What JDK is used by Android Studio? Is that the bundled JetBrains Runtime? Verify in the About dialog. Share your plugin so that we can verify it.

0

I am having now problems with the github I don't know why...

Here I share with you the android studio info:,,

And no, I didn't do what you told me of JetBrains Runtime on Android Studio..should I? Then means that all users should do it in their IDEs?



0

Download current AS version, it comes with JetBrains Runtime by default.

0

here you have the code::: https://github.com/rafads7/TaskAnnotation

 

the TaskAnnotationPlugin.jar is the plugin itself..

0

Actually, the one I have is the current AS version: https://developer.android.com/studio/index.html

 

0

AS 2.3.3 comes with _112 runtime by default which is missing JavaFX, hence users who want to use your plug-in will have to switch to a more recent Java version and use it to run Android Studio instead of _112 version. That is the only solution for your problem. Refer your users to https://intellij-support.jetbrains.com/hc/articles/206544879.

As far as I understand, AS 3.0 comes with the more recent runtime and should work out of the box.

0

Okey, so in order to use it now by myself into AS, I should do what the link says... is enough just with this part::: ??

0

Okey, it is working...!!! I want to thank you so much, you cannot imagine how stressed I was... I really appretiate your help. Thank you very much again!

Just last thing... I realize that once I close my plugin (tapping the X of the javafx window application) I am not able to click on any other menu item, or not even do right click on the code...do you know why could it be? I just saw that happens the same when I am running it on IntellIJ IDEA

0

Please attach jstack or just take thread dumps if you start your plugin under debug (or just pause during debug session):

you'll see what does the AWT thread.

0

请先登录再写评论。