Android Studio Run/Debug configuration error: Module not specified

AndroidAndroid StudioModuleGradle

Android Problem Overview


I am getting a 'Module not specified' error in my run config. I have no module showing in the drop down yet I can see my module no probs. The issue came about when I refactored my module name, changed the settings.gradle to new name.

Now when I go to project structure and select my module nothing shows in the screen, not even an error.

I'm not 100% sure, but the icon beside my module looks like a folder with a cup and not a folder with a phone.

My exact steps -

  1. Open in Android view
  2. Refactor directory name
  3. refactor module name
  4. change settings.gradle contents: name to new name

Android Solutions


Solution 1 - Android

Resync your project gradle files to add the app module through Gradle

  1. In the root folder of your project, open the settings.gradle file for editing.

  2. Cut line include ':app' from the file.

  3. On Android Studio, click on the File Menu, and select Sync Project with Gradle files.

  4. After synchronisation, paste back line include ':app' to the settings.gradle file.

  5. Re-run Sync Project with Gradle files again.

Solution 2 - Android

never mind, i changed the name in settings.gradle and synced and then changed it back and synced again and it inexplicably worked this time.

Solution 3 - Android

Try to delete the app.iml in your project directory and restart android studio

Solution 4 - Android

This issue also may happen when you just installed new Android studio and importing some project, in the new Android studio only the latest sdk is downloaded(for example currently the latest is 30) and if your project target sdk is 29 you will not see your module in run configuring dialog.

So download the sdk that your app is targeted, then run Sync project with gradle files.

enter image description here

Solution 5 - Android

You have 3 ways:

  1. Clean Project in Android Studio menu

Build -> Clean Project and use Build -> Rebuild


  1. Remove all the modules in settings.gradle
  • Open settings.gradle project
  • Remove include ':app' and other modules
  • Sync gradle
  • Add include ':app' and other modules
  • Sync gradle again

  1. Remove all code in gradle.properties
  • Open gradle.properties project

  • Remove all code

    org.gradle.daemon=true

    org.gradle.configureondemand=true

    org.gradle.parallel=true

    android.enableBuildCache=true

  • Sync gradle

  • Add code again

  • Sync gradle again

Solution 6 - Android

None of the existing answers worked in my case (Android studio 3.5.0). I had to

  1. close all android studio projects
  2. remove the project from the recent projects in android studio wizard
  3. restart android studio
  4. use import option (Import project- Gradle, Eclipse ADT, etc) instead of open an existing project AS project
  5. File -> Sync project with gradle files

Solution 7 - Android

I realized following line was missing in settings.gradle file

include ':app'

make sure you include ":app" module

Solution 8 - Android

I struggled with this because I'm developing a library, and every now and then want to run it as an application.

From app/build.gradle, check that you have apply plugin: 'com.android.application' instead of apply plugin: 'com.android.library'.

You should also have this in app/build.gradle:

defaultConfig { applicationId "com.your_company.your_application" ... }

Finally run Gradle sync.

Solution 9 - Android

If you can't find your settings.gradle file in your project directory

  1. Add settings.gradle file

  2. Add include ':app' inside the settings.gradle file

  3. Rebuild or sync your project

Your app module should appear in your configuration file.

Solution 10 - Android

I had the same issue after update on Android Studio 3.2.1 I had to re-import project, after that everything works

Solution 11 - Android

check your build.gradle file and make sure that use apply plugin: 'com.android.application' istead of apply plugin: 'com.android.library'

it worked for me

Solution 12 - Android

I would like to add some more information while I was facing this issue:

Ref: Answer from @Eli:

> 1. Cut line include ':app' from the file. > 2. On Android Studio, click on the File Menu, and select Sync Project > with Gradle files. > 3. After synchronisation, paste back line include ':app' to the settings.gradle file. > 4. Re-run Sync Project with Gradle files again.

So, let's follow the instruction and try to keep one thing in mind, that what is showing in your build configuration. Make sure you are seeing the name of your configuration app like the image below:

enter image description here

If you are seeing anything else, then the steps mentioned by @Eli (the most accepted answer) will not work.

An alternative Solution If you have a different name on the Run/Debug Configurations window and the above process is not working, please change the config name to 'app'

> then -> hit Apply -> then Ok.

After that follow this:-

> File->Sync project with gradle files (if needed).

Now check the issue will be resolved hopefully. I have faced this issue and I think it might help others as well.

Solution 13 - Android

I had to select "Use classpath of module:" drop down option and choose my module.

Solution 14 - Android

I was trying to open an old GitHub project with the latest android studio that's why got this error. I tried almost all the way that mentions in this post but none of them is work.

In my case, I update my Gradle version with my latest project, and the issue resolved. Use your latest Gradle version to resolve the issue.

enter image description here enter image description here

Solution 15 - Android

Sometimes the project doesn't load your sdk version. so manually change the this in your build.gradle file module level to your own sdk version

  1. compileSdkVersion 28
  2. buildToolsVersion "28.0.3"
  3. targetSdkVersion 28

now re-sync the your project.

Solution 16 - Android

Check your minsdkversion, compilesdkversion and targetsdkversion and ensure that you installed all those from Tools -> SDKManager in Android Studio.

e.g if your targetsdkversion is 30 and minsdkversion is 28, ensure that you installed 28, 29, 30 sdks.

Solution 17 - Android

Remove from app gradle this code

android{
    defaultConfig.applicationId="com.storiebox"
}

Solution 18 - Android

We are currently recommending AS 3.3 for exercises.

These settings will work in the current 3.3 beta version with two small changes to your project:

In build.gradle (Project), change gradle version to 3.3.0-rc02

In menu go to File -> Project Structure. There you can change the gradle version to 4.10.0

Solution 19 - Android

in my case, when I added Fragment I git this error.

When I opened THe app build.gradle I saw id("kotlin-android") this plugin in plugins.

just remove it!

Solution 20 - Android

You can clean your project and and invalidate caches / restart. After that your project might be fixed.

This solution works for me.

Solution 21 - Android

If no solution works then make sure that you opened the project from the right directory

For example, when I opened the project from app folder and from the root I got

> Module not specified

error, but when I opened it from todoapp the error had gone

example

Solution 22 - Android

Run the app, it will show 'Edit Configuration' window. Under Module - select the app (it would be <no module> ).

Then select the activity (under Launch Options)

enter image description here

Solution 23 - Android

If all above solution doesn't work then do try this solution, because in my case none of the above solution were working. I too was facing this problem and after 5 hour of hard work I am able to tell you a solution. If you are cloning project using git the I would recommend you to directly clone project using android studio. It worked for me.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFearghalView Question on Stackoverflow
Solution 1 - AndroideliView Answer on Stackoverflow
Solution 2 - AndroidFearghalView Answer on Stackoverflow
Solution 3 - AndroidvidalbenjoeView Answer on Stackoverflow
Solution 4 - AndroidPavel PoleyView Answer on Stackoverflow
Solution 5 - AndroidRasoul MiriView Answer on Stackoverflow
Solution 6 - AndroidNikos HidalgoView Answer on Stackoverflow
Solution 7 - AndroidbikramView Answer on Stackoverflow
Solution 8 - AndroidMoyoteView Answer on Stackoverflow
Solution 9 - Androidadegoke ayanfeView Answer on Stackoverflow
Solution 10 - AndroidPeterView Answer on Stackoverflow
Solution 11 - AndroidAli OzkaraView Answer on Stackoverflow
Solution 12 - AndroidA S M SayemView Answer on Stackoverflow
Solution 13 - Androiduser1300214View Answer on Stackoverflow
Solution 14 - AndroidMd Imran ChoudhuryView Answer on Stackoverflow
Solution 15 - AndroidAtif Ali KhanView Answer on Stackoverflow
Solution 16 - AndroidLincyTonitaView Answer on Stackoverflow
Solution 17 - AndroidOm Prakash SharmaView Answer on Stackoverflow
Solution 18 - AndroidpincyView Answer on Stackoverflow
Solution 19 - AndroidSana EbadiView Answer on Stackoverflow
Solution 20 - AndroidДенис ЧорныйView Answer on Stackoverflow
Solution 21 - AndroidIslam AhmedView Answer on Stackoverflow
Solution 22 - Androidtanni tannaView Answer on Stackoverflow
Solution 23 - Androidsachin pathakView Answer on Stackoverflow