How To Resolve the “Module Not Specified” Error in Android Studio

Module is basically a collection of run/build settings and source files that help you organize your project into smaller units. When you get errors like Module Not Specified in Android Studio, it’s often because the IDE can’t figure out which module to run or build. Usually, this happens when Gradle files are missing or misconfigured, or if your project structure isn’t quite right.

It can be super frustrating, especially when Android Studio throws a fit about modules that are technically there but not recognized. Sometimes a little tweak to project setup can fix it—like telling Android Studio explicitly where all your modules are, or forcing a refresh of its configs. Here’s what’s worked for a lot of folks, including some who saw this issue pop up after a Gradle sync or project import.

How to Fix the “Module Not Specified” Error in Android Studio

Specify All Modules in the settings.gradle File

This is kinda the first thing to check if Android Studio blankly refuses to recognize your modules. Because Android Studio relies on the settings.gradle file to know what’s what, missing or wrong entries there can cause the error.

The idea is to declare every module inside that file, especially if you’ve added new modules or moved stuff around. When done properly, this helps Android Studio and Gradle sync up and understand what modules it’s supposed to build or run.

On one setup it worked after just adding include 'app'. On another, I had to add multiple modules like include 'app', 'library' — all depending on how complex the project is.

  1. Open the project in Android Studio.
  2. Check if the project folder has additional modules besides the main app
  3. Find and open the settings.gradle file (it’s usually in the root directory).
  4. Add lines like include 'app', 'library' matching your module names. Make sure names are correct and match folder names (case-sensitive!).
  5. After editing, click Sync Now in the yellow banner that appears, or go to File > Sync Project with Gradle Files.
  6. Once it’s done syncing, go to Run > Edit Configurations and make sure the right module is selected.
  7. Hit Run and cross your fingers.

Sometimes, it’s just that simple—missing module declarations in settings.gradle cause Android Studio to get confused about what to build. Hopefully, this gets everything back on track.

Disable Antivirus and Manually Refresh Gradle

Some antivirus apps are weirdly aggressive and block parts of Gradle’s network or file access. If your build suddenly craps out or modules aren’t recognized, it might be because the antivirus blocked something vital.

Disabling antivirus temporarily can help, especially Windows Defender. Just make sure to turn it back on afterward. Because of course, Windows has to make it harder than it needs to be!

To do that:

  1. Hit the Start menu, then type Windows Security and open it.
  2. Go to Virus & threat protection.
  3. Click on Manage settings under that section.
  4. Turn off Real-time protection for now—this is the big one that might block stuff.

Once that’s done, you should resync your Gradle files:

  1. Back in Android Studio, go to File > Sync Project with Gradle Files.
  2. Watch the progress bar, then see if the modules are recognized now.
  3. If all looks good, give a run a shot. Sometimes, this step alone is enough to clear out weird caching issues or network mishaps.

If that didn’t help, consider rebooting after disabling antivirus, or even reboot and repeat the sync. A fresh start often clears the ghost bugs.

Delete the.idea Folder and Re-import the Project

This one feels kinda drastic but has saved many devs after Gradle or Android Studio got out of sync. The .idea folder contains a bunch of project-specific settings, and when it’s corrupted or stale, Android Studio can go rogue.

Deleting it forces Android Studio to regenerate those settings from scratch when reopening, which often fixes misconfigurations and resets module detection.

  1. Close Android Studio.
  2. In your project directory, find and delete the .idea folder.(It’s hidden sometimes, so make sure your file explorer shows hidden files.)
  3. Reopen Android Studio and open the project again.
  4. It will prompt to reload the project; let it process.
  5. You might see a yellow banner at the bottom saying Load Gradle Project. Click that and wait. It can take some minutes depending on how big the project is.
  6. When it finishes, double-check the Run > Edit Configurations dialog to ensure the correct module is selected.
  7. Now, try running the app again. Sometimes, this simple reset clears up the module recognition issues.

Note: After regenerating, you might need to redefine some IDE preferences or re-import some SDKs, but it’s usually worth it.

Lots of folks have reported that these fixes, especially messing with settings.gradle and deleting .idea, worked after other attempts failed. Sometimes, it’s just a matter of forcing Android Studio to see the project the way it’s supposed to.

Summary

  • Add all modules in settings.gradle and sync.
  • Temporarily turn off antivirus and sync manually.
  • Delete the .idea folder, reopen, and resync.
  • Double-check your project structure and run/debug configs.

Wrap-up

This bugs me every time because it’s not always obvious what triggers it—could be a Gradle update, project import, or some weird caching. But these steps usually do the trick. Messing with the settings files or invalidating caches isn’t glamorous, but it’s reliable enough to get back on track. Fingers crossed this helps someone avoid tearing their hair out. Good luck!