Warning:No JDK specified for module 'Myproject'.when run my project in Android studio

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?


Solution 1:

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:

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:

Run -> Edit configurations -> Select your build configuration -> JRE - change Default to one of actual JDK paths

Solution 4:

Restart intelliJ and import project as maven if it is a maven project

Solution 5:

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.