Fix for Gradle Error: “Module Not Specified” in Android Studio

Fix for Gradle Error: “Module Not Specified” in Android Studio

Photo of author
Written By Eric Sandler

Running into the “Module not specified” error in Android Studio? You’re not alone — this is a common issue, especially when importing or building projects for the first time. Thankfully, it’s easy to fix once you know where to look. Follow these steps and get your project building again in minutes.

Step 1: Understand the Error

The “Module not specified” error usually appears when:

  • You try to run or debug your app but Android Studio doesn’t know which module to execute.
  • Your project’s run configuration is missing or pointing to a module that doesn’t exist anymore.
  • You’ve just imported a project or renamed a module and things haven’t synced properly.

Step 2: Sync the Project with Gradle Files

This should be your first move:

  1. Click File in the top menu
  2. Select Sync Project with Gradle Files

This forces Android Studio to recheck your build.gradle files and re-link any modules. If the error was caused by a temporary sync issue, this might fix it on the spot.

Step 3: Check Your Run Configuration

  1. In the top-right corner of Android Studio, click the dropdown next to the green Run/Debug button
  2. Choose Edit Configurations
  3. Under Application, select the configuration giving the error
  4. Look for the Module dropdown and make sure it points to the correct module (usually app)
  5. Click Apply then OK

If no module is selected, Android Studio won’t know what to build or run.

Step 4: Invalidate Caches and Restart

Still stuck? Clear things out:

  1. Click File → Invalidate Caches / Restart
  2. Choose Invalidate and Restart

This clears any corrupted IDE state that might be blocking the module configuration from loading properly.

Step 5: Rebuild the Project

After restarting:

  1. Go to Build → Rebuild Project
  2. Watch the build output for any other errors that may pop up

This ensures all dependencies are correctly resolved and the build process is clean.

Step 6: Check Your Project Structure

If the error persists:

  1. Go to File → Project Structure
  2. Under Modules, make sure your app module exists and is properly configured
  3. If needed, click + Add Module to re-add one manually

Sometimes, the project imports fine, but the app module is missing entirely.

Example: Correct Run Configuration in Android Studio

To double-check your run config:

  1. Go to Run → Edit Configurations
  2. Under the Application section, select your app’s configuration (or click + to add a new one)
  3. Make sure these fields are set:
FieldExample Value
NameMyApp
Moduleapp
Activitycom.example.myapp.MainActivity
LaunchDefault Activity
Deployment TargetShow Device Chooser or USB Device
  1. Click ApplyOK

If Module is blank or incorrect, that’s the most common trigger for the “Module not specified” error.

You’re Good to Go

Once your module is properly specified and your project syncs cleanly, the error should disappear. Hit the green Run button and your app should build like normal.

Bonus Tip

If this issue keeps coming back, save a working copy of your .idea and .gradle files as backup. Sometimes, starting from a clean import and restoring these configs is faster than debugging every time.

Eric Sandler

Leave a Comment