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.
What breaks the module link
- Missing or deleted module: A module was removed or renamed, but configurations still point to the old one.
- Changed project structure: Directory or project structure changes can make modules invisible to the IDE.
- Corrupted configuration files: Damaged
.ideaor.imlfiles can break how modules are registered. - 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
- Verify the module exists: Open
File>Project Structure>Modulesand make sure every expected module is listed. - Check the Run/Debug configuration: Go to
Run>Edit Configurationsand, for each configuration, select the correct module in the "Module" dropdown. - Sync Gradle: Click
File>Sync Project with Gradle Files(or the toolbar button) and make sure the sync finishes without errors. - Recreate the configuration: If the error persists, delete the configuration, add a new one with
+>Android App, and specify the module. - Invalidate caches: Go to
File>Invalidate Caches / Restartand selectInvalidate and Restart. - Check configuration files: Look for problems in the
.ideadirectory and.imlfiles, 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
Modulessection 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 Error | Solution |
| Missing or deleted module | Check and add necessary modules in Project Structure. |
| Incorrect project structure | Review and adjust the project's directory structure. |
| Corrupted configuration files | Repair or regenerate .idea and .iml files. |
| Gradle sync issues | Run a Gradle sync and fix any underlying problems. |
| Misconfigured Run/Debug configuration | Reconfigure 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.
Related reading
- Android Studio SDK location
- Android Studio Stuck at Gradle Download on create new project
- Android Studio suddenly cannot resolve symbols
- Android Studio was unable to find a valid Jvm Related to MAC OS
- Android Support plugin for IntelliJ IDEA or Android Studio cannot open this project
- Android TensorFlow Lite interpreter How to fix DataType error cannot resolve DataType of java.lang.Float
- Android TextView Do not concatenate text displayed with setText
- Android TextView Justify Text
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo 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 courseData 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.