what to do when the java.lang.illegalSateException (Module entity with name: .... should be available) occurs?
Asked Answered
P

6

10

Alright so, i got the code from a coworker and when i start it with android studio i get this exception.

enter image description here

I guess, it might be as simple a what it states, a module is missing. But i dont know which one and the code works perfectly fine on the computer of my coworker.

I googeled the question as well, and the only anser one user gave in the intellij forum gave was, to lower the gradle version.

Thanks in advance!

Peseta answered 25/1, 2024 at 9:48 Comment(0)
I
35

I haven't gotten this error before but I did some research to help, can you try this:

  1. Rename your project directory to exactly match the value of rootProject.name in your root settings.gradle
  2. File > Invalidate Caches... > Invalidate and Restart

Source: https://youtrack.jetbrains.com/issue/IDEA-317606/Changing-only-the-case-of-the-Gradle-root-project-name-causes-exception-while-importing-project-java.lang.IllegalStateException#focus=Comments-27-7257761.0-0

Isacco answered 25/1, 2024 at 10:6 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Stollings
S
9

Just delete the .gradle and .idea files.

.gradle and .idea files

  • After that, restart and invalidate cache selecting all checkbox and restart the android studio.

restart the android studio .

Susannahsusanne answered 30/1, 2024 at 5:19 Comment(0)
E
6

Make sure the rootproject .name in your settings.gradle file is the same as your project folder name

Engelhart answered 7/2, 2024 at 13:23 Comment(0)
P
6
  • Open settings.gradle
  • rename rootProject.name = "project_dir_name"
  • Sync project with gradle files or invalidate cache and restart
Paestum answered 8/3, 2024 at 3:56 Comment(0)
B
6

A little Hack worked in my case without Invalidate/restart.

In settings.gradle file, the value of rootProject.name must be same as the project folder name.

You need to just temporarily change the value of rootProject.name and sync the project. It will try to build and will be failed with an error.

Now Just add the corect value in rootProject.name(same as project folder name). It worked like a charm form me.

Buttercup answered 9/5, 2024 at 12:50 Comment(0)
S
0

Just delete the line rootProject.name = "project_dir_name" in settings.gradle file.

Stavros answered 1/8, 2024 at 5:12 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.