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).
I am new with programing and i wanted to install netbeans in my macbook but i kept having this text " The JDK is missing and is required to run some NetBeans modules Please use the --jdkhome command line option to specify a JDK installation or see http://wiki.netbeans.org/FaqRunningOnJre for more information.”
That means you need the Java Development Kit (JDK). It is important for running files and develop those. You can download the newest version of the JDK under: https://www.oracle.com/java/technologies/javase-downloads.html
If you already have a JDK installed you must change the config file of NetBeans.
I have a new MBP (16" 2019). Downloaded a fresh copy of IntelliJ IDEA Ultimate 2020.1.1. Used SDKMan to install Java 11-zulu and latest Gradle, 6.4. Went to File->New-Project and chose Gradle. When it loads, I get a Sync error and gradle won't process in IntelliJ correctly. Everything works fine from the CLI. I tried with importing an existing gradle project, different Java and Gradle versions, all give the same vague error.
idea.log
Caused by:
org.gradle.launcher.daemon.client.DaemonConnectionException: The newly
created daemon process has a different context than expected. It won't
be possible to reconnect to this daemon. Context mismatch: Java home
is different.
I've seen other questions about this but none of those solutions are working for me and I've never had this issue before, 10 years of using IDEA on OSX.
The issue is likely caused by the incorrect Java home path specified for the JDK in IntelliJ IDEA. Make sure it points to the correct location like this:
/Users/rob/.sdkman/candidates/java/14.0.1-zulu/zulu-14.jdk/Contents/Home
On macOS /Contents/Home part of the path is significant.
If some one are using macos with Sdkman use this version: sdk install java 8.0.322-librca for sdk 1.8 or other correlated version from librca, because sdk fom zulu i always had this same problema in intellij idea with java/kotlin and gradlew...
I'm trying to get JavaFX applications to run on Android by using the Dalvik JavaFX-Android SDK (provided by the JavaFX Android porting team). So I downloaded the samples provided by the JavaFX Android porting team and have been trying to run one of them on Android without much success.
Using Eclipse with the Gradle plugin I imported the "HelloWorldFxml" sample project. Then I ran the Gradle task "./gradlew androidInstall" on the project like the README file told me. But unfortunately the task cannot execute because Gradle cannot locate my JDK:
(source: forumbilder.se)
Even though my JAVA_HOME system variable is correctly set and I havn't had a problem with it before:
(source: forumbilder.se)
Anyone that can provide some insight as to how I can fix this?
Versions: Eclipse Luna Service Release 1a (4.4.1), Gradle 2.2, dalvik-sdk-8u40-ea3, Android SDK Build-tools 21.1.2, Android SDK Tools 24.0.2
Edit: The console output when running "gradlew androidinstall" on a sample project:
Even though the error message doesn't specify it, maybe it's looking for javac in your PATH? In case it's not in there try adding ;%JAVA_HOME%\bin to the end of your PATH variable (and restart Eclipse afterwards, I've had the problem of running processes not getting changes to environment variables before).
Check the Java setting in Eclipse:
Window -> Preferences
Java -> Installed JREs
Make sure that your JDK 1.8 is listed there. If it's not, add it using the Add... button.
Once the JDK is known to Eclipse, make sure that your project's settings use that JDK as a compiler, and the Gradle plugin should be able to pick up the setting from there.
In a pinch, you should also be able to run Gradle from the command line, and it should work fine since you already set the %JAVA_HOME% variable.
Basic Note
Since the release of dalvik-sdk-8u40-ea3, and in very short time, the JavaFXPorts team has released a few new versions, all of them simplifying all the process of porting a JavaFX application to Android or iOS.
They released dalvik-sdk-8u40-ea4 and they announced the release of a new plugin, that will simplify to the minimum the steps to create a mobile application from JavaFX.
While this answer may not help the OP in his particular problem, definitely it will help him and others, since everything is really simplified.
New approach
With this plugin, there's a new way of creating the HelloWorldFxml application for Android.
The new javafxmobile-plugin allows you to generate the apk with a single 'build.gradle' file.
You can find this an other basic samples here, and download the repository here.
You won't need to edit a single line, just type this on the command line, on the root of the sample, with your device connected:
gradlew androidInstall
As for previous releases, you will need JDK8u40 and Android SDK installed. No need for dalvik-sdk though, it's retrieved by the plugin.
Notice that you can open these samples from your IDE, so you will be able to modify them, and run them locally or build again the apk for your device.
Had this problem, too.
My proberties:
-Windows 7
-Dalvik SDK (dalvik-sdk-8u60-b5)
-JDK 8 (newest Version 8_60 / IMPORTANT: JDK not JRE)
-And I tried also the HelloAndroid project provided by the Dalvik-SDK-download.
So i execute the command line: gradlew installDebug
My probelm was nearly the same.
"Fail to find JDK. Please make sure there is a JAVA_HOME or JAVA8_HOME systemvariable."
#1
Created these proberties. Just like described in this post:
How to set java_home on Windows 7?
So to make everything sure, I created both with the same path. Cause I don't know exactly which one is used by gradle.
#2
This is really the hack that helps me out. Found this also in StackOverflow.
Write in your build.gradle under the android{..} stuff this line:
retrolambda {
jdk 'C:/Program Files/Java/jdk1.8.0_60' //<--your JDK-path
}
it looks like that
Then execute the same command line again and it worked for me.
I think only the 2. steps was the solution, cause I guess gradle don't look for the variable if there is a direct path to the jdk.
I've been working on my desktop computer which has openjdk 7.
When I copy a Grails project onto my laptop, which has Oracle's JDK v7, I'm having a problem with the classpath.
I've checked the classpath and everything seems fine.
Here's the text that GGTS shows:
The archive: /usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar which is
referenced by the classpath, does not exist
I set the JAVA_HOME inside /etc/profile.
I installed gvm in order to make easier Groovy and Grails setup.
I hope you could help me
:)
I then went to the RUN menu option at the top and selected run configuration
It was on : Grails \ {Myproject} (run-app)
On the right for this run-app there is JRE options
under JRE ensure you have the same JRE defined as project in this case 1.6
I'm guessing that your JRE reference in your project is bad. Is your desktop windows and your laptop a mac or linux (or vice versa)?
Try these things:
Does the /usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar path exist on the broken system?
Can you create other kinds of projects on the broken system?
Can you create a new Grails project from scratch inside of the broken GGTS?
What happens if you run Grails -> Refresh dependencies on the project?