Gradle SwingBuilder: “Toolkit not found: apple.awt.CToolkit” error

不想你离开。 提交于 2019-12-25 02:58:27

问题


I have a Gradle task that is supposed to prompt if the user wants to continue or not (part of a larger task for my Android app).

I'm using SwingBuilder to to try construct a dialog but I'm getting the following error when I try to build:

Error:(94) Execution failed for task ':XXXXXX:ask'.
> Toolkit not found: apple.awt.CToolkit    

Obviously, I don't have something installed on my Mac but I'm not sure what I need to install. Is this a Java dependency? Or Gradle? (Googling this does not help very much either - the only relevant link is something to do with Google AppEngine which does not help me much).

Here's the task:

task ask << {
    def pass = ''
    new SwingBuilder().edt {
        dialog(modal: true, 
                title: 'Continue',
                alwaysOnTop: true, 
                resizable: false, 
                locationRelativeTo: null, 
                pack: true, 
                show: true 
        ) {
            vbox { 
                label(text: "Are you sure you want to continue?")
                button(defaultButton: true, text: 'Continue', actionPerformed: {
                    //do something
                    dispose(); 
                })

                button(defaultButton: true, text: 'Cancel', actionPerformed: {
                    //do something
                    dispose(); // Close dialog
                })
            }
        }
    }

回答1:


According to this issue on GitHub, the problem appears to be with the fact that IntelliJ IDEA runs on Java 6 by default. You'll need to force it to run with Java 7 instead, as described in this JetBrains support article.

One thing to bear in mind is that IntelliJ has problems with Java 7 and above on Mac, which is why it defaults to Java 6. You can find more details in that support article I linked to.



来源:https://stackoverflow.com/questions/31400831/gradle-swingbuilder-toolkit-not-found-apple-awt-ctoolkit-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!