Warning:No JDK specified for module 'Myproject'.when run my project in Android studio
AndroidAndroid StudioAndroid Problem Overview
When I run my project, I found the module in error
then I click in founding an error "Warning:No JDK specified for module 'Myproject'.when run my project.",vI setting JAVA_HOME
and JDK_HOME
in my path. hope Anyone can share your idea?
Android Solutions
Solution 1 - Android
it happened for me when I deleted the jdk and installed new one somehow the project kept seeing the old one as invalid but couldn't change, so right click on your module -> Open Module Settings -> and choose Compile Sdk Version.
Solution 2 - Android
Go to File->Project Structure->SDK Location and check if the path for SDK and JDK location specified by you is correct. If its not then set the correct path. Then It will work.
Solution 3 - Android
Run -> Edit configurations -> Select your build configuration -> JRE - change Default to one of actual JDK paths
Solution 4 - Android
Restart intelliJ and import project as maven if it is a maven project
Solution 5 - Android
Restart IntelliJ and reimport the Project and import it as maven. It should work then. The error occurs because IntelliJ keeps track of module through .iml files so any changes in these files can cause this error. Reimporting the project regenerates the .iml file so generally, it solves the error.
Solution 6 - Android
ReImport the dependencies if it is a maven project
Solution 7 - Android
Syncing Gradle fixed this issue for me.
Solution 8 - Android
I was able to fix it using the answer here: https://stackoverflow.com/a/32176571/1174024 But I have 150 modules. So I would have had to perform this step 150 times.
So I needed to do it a different way.
So first close the existing project, then Import it again, In the first step of the wizard choose "Gradle" project. Then the next step of the wizard has the Gradle project properties. Here it's going to ask you for, among other things, the Java SDK to use. The default will be "Project SDK". Do not use this default, instead hand pick your Java SDK from the list. Then finish the import.
Now the problem should go away.
Solution 9 - Android
In Linux I've resolved this by deleting all the folders with names starting as ".AndroidStudio" in my home directory and then rerunning the Android Studio.
Solution 10 - Android
I had the same issue. I ended up re-importing the entire project to fix the problem.
Solution 11 - Android
If you're on Intellij, right click on pom.xml and Maven > Unlink project. Then reload the project by right clicking the pom.xml file again
Solution 12 - Android
My issue was solved by simply refreshing the modules View > Maven Projects. There is refresh icon which refreshes your entire project(s)
How I got this error : I imported a project (Let's call this A which is main project) first and added the remaining projects (B,C,D etc) as modules to this one as I needed all my projects to be shown in one package folder. I deleted the old (A) Project and cloned it again from repo. The IntelliJ reloaded the (A) project but when I try to run, the project wasn't compiling saying "Warning:No JDK specified for module 'B'".
Solution 13 - Android
In my case, I was using ionic capacitor. After running the command npx cap open android
I tried to run the app on my device using android studio, but the Gradle was syncing in the background so I was getting this error. Just let the Gradle sync and app building process finish and then run the app.
Solution 14 - Android
This just happened to me for apparently no good reasons. I invalidated the cache and restarted the project and thus, the issue was solved for me.
Solution 15 - Android
I had the same problem running a simple java projet in Intellij, getting the ,message: "java: JDK isn't specified for module 'my module' " I resolved it, I followed these steps:
- Right click on the module name (my module)
- Click Open Module Settings
- Open the tab Dependencies
- Under Module SDK,change the SDK version
- Click OK and rerun