Android Studio
Run/Debug Configuration
Module Not Specified
Error Fix
Troubleshooting

Android Studio Run/Debug configuration error: Module not specified

Codemia Knowledge Hub ·

The "Module not specified" error means a Run/Debug configuration in Android Studio is not linked to a valid module. Open Run > Edit Configurations and pick the correct module in the "Module" dropdown. If no module is listed, sync the project with Gradle, and if that fails, recreate the configuration or use File > Invalidate Caches / Restart.

In an Android project, a module is a collection of source files, build settings, and resources. The IDE needs each run configuration to point at one so it can build and deploy the right code.

  1. Missing or deleted module: A module was removed or renamed, but configurations still point to the old one.
  2. Changed project structure: Directory or project structure changes can make modules invisible to the IDE.
  3. Corrupted configuration files: Damaged .idea or .iml files can break how modules are registered.
  4. Gradle sync failures: If Gradle does not sync properly, it may not recognize all modules, and configurations break.

Fixing "Module not specified" step by step

  1. Verify the module exists: Open File > Project Structure > Modules and make sure every expected module is listed.
  2. Check the Run/Debug configuration: Go to Run > Edit Configurations and, for each configuration, select the correct module in the "Module" dropdown.
  3. Sync Gradle: Click File > Sync Project with Gradle Files (or the toolbar button) and make sure the sync finishes without errors.
  4. Recreate the configuration: If the error persists, delete the configuration, add a new one with + > Android App, and specify the module.
  5. Invalidate caches: Go to File > Invalidate Caches / Restart and select Invalidate and Restart.
  6. Check configuration files: Look for problems in the .idea directory and .iml files, especially after merging branches or migrating projects. Re-importing the project to regenerate them often fixes it.

Example: after renaming a module

A developer refactors a project and renames a module. The existing configurations still reference the old name, so Android Studio reports "Module not specified." The fix:

  • Step 1: Confirm the new name in the Modules section of Project Structure.
  • Step 2: Update the Run/Debug configurations to use the new module name.
  • Step 3: Resync Gradle so dependencies pick up the new name.
  • Step 4: If problems persist, invalidate caches and restart Android Studio.

Causes and fixes at a glance

Cause of ErrorSolution
Missing or deleted moduleCheck and add necessary modules in Project Structure.
Incorrect project structureReview and adjust the project's directory structure.
Corrupted configuration filesRepair or regenerate .idea and .iml files.
Gradle sync issuesRun a Gradle sync and fix any underlying problems.
Misconfigured Run/Debug configurationReconfigure by selecting the correct module from the dropdown.

Avoiding it in multi-module projects

  • Keep module names and structure clear and consistent.
  • Clean the project and sync Gradle regularly to head off configuration problems.
  • Keep Android Studio updated for the latest fixes to configuration management.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms