Gradle Constants undefined
Answered
Hi,
I tried to import org.jetbrains.plugins.gradle.util.GradleConstants. However, IntelliJ gave me a "Cannot resolve symbol plugins".
I looked around the internet and could not find any solution to this. Can anyone please help me?
Thanks,
Dan
Please sign in to leave a comment.
You need to add Gradle plugin JARs to your IntelliJ Platform SDK.
If this helps, I have installed the Gradle plugin into IntelliJ.
Hi,
So I downloaded Gradle and included it's lib folder, where there are bunch of gradle.jar files,
into my project. The project is still complaining that it cannot find GradleConstants. I included the
gradle jars into my project and added in the External Library component of my project through the project structure option.
Any help would be greatly appreciated.
Dan
You need to include contents from IDEA_HOME/plugins/gradle/lib to your IntelliJ Platform SDK
Ahhh, found it. Much appreciated :)
So, I included all of the JARs.
When I compiled my project, code compiles but when I run the code, I got a
run time exception like:
java.lang.NoClassDefFoundError: com/google/wireless/android/sdk/stats/AndroidStudioStats$GradleTaskExecution
at Buttons.CompileAndAnalyzeMain.actionPerformed(CompileAndAnalyzeMain.java:34)
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:199)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:215)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$2(ActionMenuItem.java:315)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:920)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:130)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:295)
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:91)
at com.intellij.openapi.application.TransactionGuardImpl.access$300(TransactionGuardImpl.java:41)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:116)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:126)
at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:112)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:308)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at com.apple.laf.ScreenMenuItemCheckbox.itemStateChanged(ScreenMenuItemCheckbox.java:193)
at java.awt.CheckboxMenuItem.processItemEvent(CheckboxMenuItem.java:389)
at java.awt.CheckboxMenuItem.processEvent(CheckboxMenuItem.java:357)
at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:351)
at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:339)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:761)
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:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
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:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:843)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:679)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:391)
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: com.google.wireless.android.sdk.stats.AndroidStudioStats$GradleTaskExecution PluginClassLoader[com.your.company.unique.plugin.id, 1.0]
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:64)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
I included all of the JARs in the gradle and android plugins. Could I be missing one JAR?
Much appreciated,
Dan
This class is bundled with AndroidStudio. Please make sure you have correct dependencies in your plugin and/or check your IntelliJ SDK to include all necessary JARs. http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
Oh I see. So in the plugin.xml part, in the <depends> tag, I should replace
it with com.intellij.modules.androidstudio? I did that, but IntelliJ isn't liking it :(
I doubt you want your plugin to run only in AndroidStudio? It looks rather like a classpath/deployment problem with your IntelliJ Platform SDK, try recreating it and/or deleting the sandbox.
Ya, it turns out that some of my gradle classes work on Android Studio but some of them just throws
a class def not found error. Just a side note, I only want my plugin to work on Android Studio because
this is for a research study using Android Studio. What I was trying to do is to compose something
like a Gradle Build message listener plugin for Android Studio, where every time
I hit the build button, the output of the gradle build will be directed to a text file and
on the output console. I tried using an ExternalSystemTaskNotificationListenerAdapter,
but after hitting the gradle build in Android studio, the code did nothing.
The only work around I see in this problem is to have the plugin execute a shell script using
a pre-written bash script with compilation commands for building an app
using command line. That's the only solution I have for this plugin. I tried
deleting the sandbox in the IntelliJ cache folder on my Mac, but the same problem
still persists, which is really strange :/
Can you confirm what exactly you put in the plugin.xml?
I was getting the same error, but after adding this line, it worked for me. Maybe for you too?