Gradle sync fail for a Grails project in IntelliJ IDEA - java

I'm using IntelliJ IDEA 2017.3 and having trouble with a basic project in Grails in it - when Gradle starts syncing the project after starting up the IDE, all the checkmarks are green and labeled as "OK", my Messages tab is empty but still I get an alert on top of the editing pane reading "Gradle project sync failed. Basic functionality (e.g. editting, debugging) will not work properly".
I've tried removing the .gradle folder, the Restart and Invalidate option, giving IntelliJ a local path to Gradle as opposed to just telling it to use the default - all to no avail. I'm behind a corporate proxy but it is set up in IntelliJ so it shouldn't be blocking anything (especially since all the syncing seems to be working just fine).
What could be the problem? Versions of my stack:
Grails Version: 3.3.8
Groovy Version: 2.4.15
JVM Version: 1.8.0_181
Gradle Version: 3.5
I've tried ensuring that proxy's not the problem according to #dkb suggestion but it does not seem to be malfunctioning - I did Invalidate and Restart again and after running bootRun, Gradle correctly downloaded Apache Ant to run the application so it doesn't seem likely to be the culprit here.
IntelliJ also kept nagging me for Android SDK (who knows why but OK) which I could not install "normally" in the corporate setting but in the end I did provide it through IDEA's Settings -> System Settings -> Android SDK -> Edit and downloading some arbitrary API and the SDK tools through there so it shouldn't be the problem either (or at least I presume it shouldn't).
In line with #y.bedrov's suggestion, I am attaching the log after reproducing the issue (external link cause it exceeds SO's post character limits).

Related

Cannot resolve production code in tests after Android Studio Chipmunk automatically created modules

I'm currently using Android Studio to develop a multi-module project by test-driven-development methods. It went well until I updated my IDE to Android Studio Chipmunk from previous Bumblebee.
When I opened the project after the update, it seemed that AS automatically generated some modules for me. As you can see in the pic, those new names such as [main] and [unitTest] appeared in the project view automatically.
modules generated automatically
After this, I found that the classes and methods of my production code could not be resolved in my test code. AS told me after I pressed Alt+Enter that I should add dependency to the main module of my production code. And it added one line in the build.gradle file: "testImplementation project(path: ':app')". After syncing the gradle build, nothing had changed and it still could not resolve methods in my production code. I can still run the tests by executing gradle test tasks, but it is weird that I cannot use production code in my test code directly.
UPDATE:
For further information, I think this is a problem caused by the update from Intellij 2021.1 to 2021.2, since I re-installed AS Bumblebee and all seems worked fine. I also found this issue in JetBrains YouTrack that has an exactly same problem with me. Here is the link: https://youtrack.jetbrains.com/issue/IDEA-275566/Class-not-found-after-intellij-upgrade-2021-1-2-2021-2
This issue remains open and I've tried some other developers' reply in this issue to delete the .iml files, but the problem remains. I think Intellij 2021.1 and 2021.2 generate different .iml file in the .idea folder.
I was having the same issues in the first Android Studio Chipmunk release - all of my unit test source code was peppered with "Cannot resolve symbol" errors, but the code would still compile and run, and the tests would pass.
I found that I could temporarily workaround (i.e., "fix") the issue by adding a line to the build.gradle file like:
testImplementation project(path: ':shared:library:module')
But today I upgraded to the new Chipmunk release, with details:
Android Studio Chipmunk | 2021.2.1 Patch 1
Build #AI-212.5712.43.2112.8609683, built on May 18, 2022
Runtime version: 11.0.12+0-b1504.28-7817840 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
And the issue no longer occurs. I'm guessing the folks working on the IntelliJ platform found and patched the issue. 🙌

Gradle not working after updating Android Studio

Gradle does not work at all, even gradle -v after updating android studio (4.3.1). I'm not pretty sure Android Studio caused this issue or not.
I installed Gradle from sdkman. The Gradle version is 6.6.1. When I run any Gradle command in terminal, the process keep running but nothing display. The path is not an issue here. Computer recognize Gradle itself.
Do you know any ideas to fix the issue?
I already uninstall/install Gradle, remove .gradle folder, restart a computer, remove cache and stuff like that...
Android Studio likes to use it's bundled JDKs and SDKs by default and change the location of it's settings every few releases. It doesn't like when you try to customize settings to your preferences, even something as trivial as choosing your own default project save location.
Currently (in version 4.2.x), I could only find gradle path in global settings, which turns out that even if you set global setting for gradle path, you would still need to configure it per project level.
So for sake of sanity, forget global settings and configure it per project level.
There are some forum discussion which suggests that android studio automatically switched kotlin compiler or java compiler from your gradle settings, but there are some conflicting articles too.
If you try to discuss it on their forum, they will tell you it's bad decision to change jdk because of compatibility reasons, won't help you much. This is based on my multiple bad experiences on their forum. Choosing your own JDK, Kotlin, build-tools etc has been active sore-point with community.
PS: Kotlin compiler settings is available in Other settings.

Cannot access script base class 'org.gradle.kotlin.dsl.KotlinBuildScript'

When I create an empty project with Gradle Kotlin DSL, even without any modifications, it would prompt Cannot access script base class 'org.gradle.kotlin.dsl.KotlinBuildScript'. Check your module classpath for missing or conflicting dependencies The project can run, but the syntax highlighting and autocompletion for build.gradle.kts don't work.
What I've tried
https://github.com/gradle/kotlin-dsl-samples/issues/1308
Changing gradle executable to gradle-kotlin-dsl-5.2-20190122225509+0000-all.zip
https://youtrack.jetbrains.com/issue/KT-38296
Remove empty SDKs in Project structure dialog
Invalidate caches and restart
Reinstalling Java 11 brew install java11
Switching to official oracle JDK 15 ​brew install oracle-jdk
https://youtrack.jetbrains.com/issue/KT-41141
Re-adding SDKs in the SDK menu
Adding /Kotlin/kotlinc/lib to Kotlin SDK's classpath
http://youtrack.jetbrains.com/issue/IDEA-245027
Deleting the cache folder manually
System
IntelliJ IDEA 2020.3.1 (Ultimate Edition)
Build #IU-203.6682.168, built on December 29, 2020
Licensed to Hykilpikonna Gui
Subscription is active until November 28, 2021.
For educational use only.
Runtime version: 11.0.9.1+11-b1145.63 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.7
GC: ParNew, ConcurrentMarkSweep
Memory: 1998M
Cores: 6
Registry: debugger.watches.in.variables=false, js.debugger.webconsole=false
Non-Bundled Plugins: CMD Support, Rider UI Theme Pack, Statistic, com.alayouni.ansiHighlight, com.intellij.ideolog, net.vektah.codeglance, String Manipulation, com.alibaba.p3c.smartfox, wu.seal.tool.jsontokotlin, com.demonwav.minecraft-dev, lermitage.intellij.extra.icons, com.github.masahirosuzuka.PhoneGapIntelliJPlugin, Dart, io.flutter, deno, org.jetbrains.kotlin, com.cybrosis.catdea, siosio.kodkod, izhangzhihao.rainbow.brackets, org.jetbrains.plugins.ruby, Pythonid, org.jetbrains.plugins.vue, tv.twelvetone.intellij.plugins.intellivue, ru.meanmail.plugin.requirements
Answer credit to #AlexeyBelkov - Answered here: https://youtrack.jetbrains.com/issue/KTIJ-893
The syntax highlighting feature worked after:
Delete ~/.gradle/caches
Delete ~/Library/Application\ Support/Library/JetBrains/IntelliJIdea2020.3 (or ~/.cache/JetBrains/IntelliJIdea2020.3 for ubuntu/linux users)
Delete <project dir>/.gradle
Delete <project dir>/.idea
Start IDEA and reimport the project.
In my case (the OS is Windows 10) it was enough to:
Delete C:\Users\<you>\AppData\Local\JetBrains\IntelliJIdea2021.1\caches
Restart IntelliJ IDEA.
Click "Load Script Configurations" when it appears after re-indexing.
Thanks #MichaelBöckling for a hint!
Mac OS:
File -> Project Structure -> SDK Location -> click on Gradle Settings
Modify the Gradle JDK
File -> Invalidate Caches...
Close the Android Studio. (Mine was version 2021.2).
Delete jdk.table.xml from Android studio's config folder .
Open Android Studio and configure JDK in Gradle Settings (Project
Structure -> SDK Location -> Gradle Settings).
Found the solution from JetBrain's issue tracker.
Worked for me after I'd deleted:
Delete <project dir>/.gradle
Delete <project dir>/.idea
Guided Cache Recovery (IntelliJ IDEA 2021.3+)
IntelliJ IDEA versions from 2021.3 and on (as of writing, available from JetBrain's Early Access Program, or EAP) has a featured called "Guided Cache Recovery" (File, Run Guided Cache Recovery...). While I can't find any documentation yet about this feature, it appears to give the user the ability to apply diagnostic/recovery steps, one at a time, to fixing any cache issues.
For me, the problem reported by the OP was resolved at step 2: "Rescan Project Indexes".
The really cool thing about this is that, not only did it fix my problem, but IntelliJ then created an issue report with details about the problem found, and gave me the option of submitting this report to JetBrains via the crash reporter. This tells me that JetBrains appears to be serious about fixing these issues for users, and about resolving their root causes.
Permissions Issues in .idea, .gradle, or gradle
Another possible problem is permissions issues in one of the .idea, .gradle, or gradle directories. For example, running a rootfull docker container, mounting the project as a volume (for example, to run a tool like Qodana) could cause some files to become owned by root unless the appropriate Docker options are used. If this issue is noticed, reset permissions with chmod and chown and then sync again in IDEA.
I set the project SDK to Kotlin under Project Settings > Modules. I also set the SDK in Plaftorm Settings > SDKs although I don't know if that's required. And just in case I restarted IntelliJ with File > Invalidate Caches / Restart ...
For IntelliJ 2021.1, I had to delete the caches folder at:
~/Libary/Caches/JetBrains/IntelliJIdea2021.1/caches
For me, solution was to install a separate JDK version (I installed Temurin JDK 17). I then simply set it to JAVA_HOME and used it in the AS and the errors disappeared.
In my case I had to set the Java version in IntelliJ -> Settings -> Build -> Gradle to 1.8 to match the projects Java version
You need to delete de cache at
~/.gradle/caches
But an easier way is to do it from IDE, under file menu
you will find "Invalidate Caches" option
Hope it works for you
My solution is as shown below
I tried but
The method below didn't work.
use in android studio android ver AndroidStudio2022.1
remove ~/Library/Caches/Google/AndroidStudio2022.1/caches
remove /.gradle/caches
In my case, I had to install the previous IDE version (2021.1.3).

IntelliJ plugin development freezes target IntelliJ instance

I am building a very simple IntelliJ plugin, and using IntellIJ CE (2019.1) as my target for build smoke-testing/debugging, deploying via the OOTB IntelliJ Plugin Run Configuration.
Whenever I perform a Run/Debug, it opens IntelliJ CE as expected (as Main java process), lets me select a project to open. Once a project is opened and the IntelliJ UI loads, I have about 5-10 seconds before the UI becomes unresponsive and I get the spinning beachball. I notice that the Main java process (which is for the CE instance), starts to gobble up memory jumping to 5-6GB over the next few seconds (on my 16GB machine). At this point, I can't do much except stopping the process.
Initially, I thought it was my code (perhaps creating an unintentional infinite loop), but I commented everything out of my plugin.xml except a fileType extension (which is basically a Bean), and it still does it. I continued my investigation by grabbing a few other IntelliJ plugin projects from GitHub, and running those (unmodified), to the same effect!! So I don't think its anything to do w/ my plugin in particular.
I've taken thread dumps of the CE process, but nothing jumps out (specifically looking for traces that contain my packages).
Lastly, I've built the plugin as a deployable Jar, and deployed it into both CE and Ultimate, and it doesn't freeze anything up. So it appears this has something to do with the Plugin deployment RunConfiguration (which I've left w/ default params).
I'm on macOS, running the latest (as of this post) IntelliJ 2019.1. I'm developing on IntelliJ Ultimate and deploying to IntelliJ CE (2019.1).
Resolution w/ screenshots based on the selected correct answer:
Create a New IntelliJ Plugin Development SDK pointing at IntelliJ CE install, and set as the Project's SDK
Create a New JDK that points to the RJDK downloaded from bintray
Assign the JDK created in step 2, as the JDK for the Puggin Development SDK created in Step 1 (via the SDKs tab)
Set the Plugin Run Configuration to use the IntelliJ CE SDK.
Run the Plugin run configuration, and CE will open with the plugin "hot deployed" to it!
Use JetBrains Runtime 8 or 11 version from https://bintray.com/jetbrains/intellij-jbr or from your main IntelliJ IDEA installation to run the sandbox IDE version. You can specify it in the JRE field of the plug-in Run/Debug configuration.

IntelliJ IDEA 13.1 is missing Run/Debug windows

After updating my IntelliJ IDEA (from 13.0.3 to 13.1) the Run/Debug windows do not show. The corresponding menu entries in View | Tool Windows are deactivated.
I have tried editing .idea/workspace.xml or using the plugin "ToolWindow Manager" to show them manually, however then the windows are empty - no buttons or anything.
Help | About shows the correct Java JRE.
How can I bring them back?
Update: problem solved, see comments: examine log file and uninstall the plugin that is throwing an exception
Perhaps you have a plugin that is disrupting the execution of the ide?
I had very similar issue today when upgrading from 13.0 to 13.1. None of my gradle tasks were running and the Run/debug windows were not appearing. When I started one of my run targets it froze and did not start until I exited the IDE.
After looking at the idea logs in [userdir]/.IdeaIC13/system/log I found the idea.log riddled with exceptions from the plugin GrepConsole. I probably had an old version of this plugin. To resolve the issue I just uninstalled the plugin using the IDEA plugin uninstall feature. After restarting IDEA 13.1 the IDE is working just fine.
A support request was sent to Intellij on this with these findings:
https://intellij-support.jetbrains.com/requests/24625
and also the author of the GrepConsole plugin was alerted here: http://plugins.jetbrains.com/plugin/7125?pr=phpStorm
For me the windows were simply under "Services". (Alt+8)

Categories

Resources