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

Android Studio is the official Integrated Development Environment (IDE) for Android app development. It provides tools for coding, debugging, testing, and building Android applications using Gradle. However, developers may sometimes encounter the “Module not specified” error when trying to run, build, or debug a project. As a result, Android Studio may disable the Run button, fail to create a run configuration, or prevent the project from building successfully.

This error is usually caused by a missing or corrupted Gradle configuration, an invalid run configuration, an improperly imported project, sync failures, deleted module files, or incorrect project structure. In some cases, Gradle cache corruption, plugin incompatibility, or changes to project files can also cause Android Studio to lose track of the application’s modules.

Fortunately, you can usually resolve the issue by syncing the Gradle project, recreating the run configuration, verifying the project structure, and rebuilding the project. In this guide, we’ll walk you through the most effective methods to fix the “Module Not Specified” error in Android Studio on Windows 10 and Windows 11.

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

Before you begin, verify that your project opens without Gradle sync errors. If the project fails to sync, resolve those issues first, as Android Studio cannot detect modules correctly until the project configuration is valid.

1. Sync the Gradle Project

Gradle synchronization rebuilds the project’s module information.

  1. Open your project in Android Studio.
  2. Click Sync Project with Gradle Files.
  3. Wait for the sync to complete.
  4. Check whether the module appears in the Run configuration.

Many module-related issues are resolved after a successful Gradle sync.

2. Verify the Run Configuration

The selected run configuration may no longer reference a valid module.

  1. Click the Run Configuration drop-down.
  2. Select Edit Configurations.
  3. Choose your Android App configuration.
  4. Verify that the Module field is populated.
  5. Select the correct app module if necessary.
  6. Apply the changes.

A missing module selection is one of the most common causes of this error.

3. Recreate the Run Configuration

If the existing configuration is corrupted, create a new one.

  1. Open Edit Configurations.
  2. Delete the problematic configuration.
  3. Click +.
  4. Select Android App.
  5. Choose the correct module.
  6. Save the configuration.

A fresh configuration often resolves invalid module references.

4. Check the Project Structure

The module may not be recognized by the project.

  1. Open File > Project Structure.
  2. Select Modules.
  3. Verify that your app module appears.
  4. Check that the module has no errors.
  5. Apply any required corrections.

If the module is missing, it may not have been imported correctly.

5. Verify the settings.gradle File

Android Studio uses the Gradle settings file to identify project modules.

  1. Open the project’s settings.gradle or settings.gradle.kts file.
  2. Verify that your application module is included.
  3. Save any changes.
  4. Sync the project again.

If the module isn’t listed, Android Studio won’t recognize it.

6. Check the build.gradle Files

Incorrect Gradle configuration can prevent module detection.

  1. Open the module’s build.gradle file.
  2. Verify that no syntax errors exist.
  3. Ensure the Android plugin is configured correctly.
  4. Sync the project.

Gradle errors often prevent Android Studio from loading project modules.

7. Invalidate Caches and Restart

Corrupted IDE caches can cause Android Studio to lose project metadata.

  1. Open File.
  2. Select Invalidate Caches / Restart.
  3. Choose Invalidate and Restart.
  4. Wait for Android Studio to rebuild its indexes.

This clears cached project information and refreshes module detection.

8. Rebuild the Project

A clean rebuild recreates project artifacts.

  1. Open the Build menu.
  2. Select Clean Project.
  3. After cleaning finishes, choose Rebuild Project.
  4. Wait for the build to complete.

Rebuilding helps regenerate missing project metadata.

9. Delete the .idea Folder and Re-import the Project

Corrupted project configuration files may cause module problems.

  1. Close Android Studio.
  2. Delete the .idea folder.
  3. Reopen Android Studio.
  4. Import the project using the root Gradle directory.
  5. Allow Gradle to sync.

Android Studio recreates the project configuration automatically.

10. Update Android Studio and Gradle

Older IDE or Gradle versions may contain compatibility issues.

  1. Check for Android Studio updates.
  2. Update the Android Gradle Plugin if necessary.
  3. Update the Gradle Wrapper to a supported version.
  4. Sync the project.

Using compatible versions improves project stability.

11. Repair Corrupted System Files

Although uncommon, damaged Windows files can affect Android Studio.

  1. Open Command Prompt as Administrator.
  2. Run:
sfc /scannow
  1. After the scan completes, run:
DISM /Online /Cleanup-Image /RestoreHealth
  1. Restart your computer.

These tools repair Windows components that applications depend on.

12. Clone or Restore the Project Again

If important project files have been deleted or corrupted, restoring a clean copy may be the fastest solution.

  1. Clone the project from your version control system.
  2. Or restore it from a backup.
  3. Open the project in Android Studio.
  4. Allow Gradle to sync completely.
  5. Verify that the module appears.

A fresh copy eliminates issues caused by damaged project files.

Conclusion

The “Module Not Specified” error in Android Studio is usually caused by invalid run configurations, Gradle sync failures, corrupted project metadata, or incorrect project structure. In most cases, syncing the Gradle project, recreating the run configuration, verifying the settings.gradle file, and rebuilding the project will resolve the issue.

If the error persists, invalidate Android Studio’s caches, delete the .idea folder, update Android Studio and Gradle, or restore a clean copy of the project. Maintaining a properly synchronized Gradle project and using version control will help prevent similar module configuration errors in the future.

Posted by Raj Bepari

I’m a digital content creator passionate about everything tech.