243

I've imported a project to Android Studio with several subprojects.

I want to run a subproject.

I successfully made this subproject's build.gradle as a module.

In order to run it, I went to Run > edit configurations > + > Android Application.

Problem: When I try to select a module, none show up in the drop down list.

Why is this?

EDIT: it shows up as a module under Groovy but not showing under Android Application. How do I get it to show up under Android Application?

Zoe
  • 27,060
  • 21
  • 118
  • 148
user1161310
  • 3,069
  • 3
  • 21
  • 27

36 Answers36

165

Make sure your build.gradle is

apply plugin: 'com.android.application'

not

apply plugin: 'com.android.library'

After you have changed, please sync your gradle again.

enter image description here

xDragonZ
  • 12,502
  • 6
  • 37
  • 52
  • 3
    That fixed my issue! Only synced with gradle again and AS recognized it. – StefMa Feb 13 '15 at 08:27
  • 2
    I'm looking for this answer since 1h – Anthone Jun 15 '15 at 21:59
  • 13
    For me just clicking the "Sync Project with Gradle Files" fixed it. I was really worried I had busted things beyond repair. – startoftext Aug 17 '15 at 06:13
  • Before doing any changes to your gradle file, just close the project *file-->close* and then re-open the project. It may be Android Studio caching problem. – Chanaka Fernando May 06 '19 at 21:47
  • It is neither first nor second for me. I have only "// Top-level build file where you can add configuration options common to all sub-projects/modules." in build.gradle file. – Clarity Jun 12 '20 at 08:51
93

I had similar issue when I selected parent directory of my project, I resolved by Close Project -> Delete Project from Android Studio -> Import Project by selecting right build.gradle file.

Make sure you select right build.gradle file while import.

Prakash
  • 4,479
  • 30
  • 42
75

In Android Studio 3.1.2 I have faced the same issue. I resolved this issue by click on "File->Sync Project with Gradle Files".This works for me. :)

Pankaj Negi
  • 1,558
  • 1
  • 16
  • 23
  • 1
    Works also on 3.3.1 – Davide Mar 04 '19 at 19:59
  • 1
    @aldok, not, it is not an accepted answer. It is a rare situation, when everything worked, but stopped. In many cases it won't work. – CoolMind Apr 11 '19 at 09:33
  • should be the ACCEPTED answer. +1 – Hissaan Ali Mar 29 '20 at 06:43
  • In some cases, this would've run on launching a new project in Android Studio, but it ran into a Gradle error which stopped it from completing - hence the lack of a configuration. Android Studio should have the Gradle error shown in the log output panel in that case. – Chris Hayes Nov 30 '22 at 17:29
74

I fixed this by adding facets in Module settings. They were missing. right click on project > open Module settings > Facets > Add facets ( "+" sign at the top ) > Android. After adding facets you will have modules.

UPDATE:

For latest version of gradle, Facets have been removed, you can directly add modules now. right click on project > open Module settings > Add module ( "+" sign at the top ) > Phone and Tablet Application (Now you can create a new module and configure it).

sahil shekhawat
  • 1,208
  • 12
  • 14
  • 3
    I have no clue what a facet is in this context (old name for module?) but the options seem to be missing in AS 1.0 – G_V Dec 10 '14 at 13:26
  • @G_V the option 'Facets' exists under 'Project Settings' if you follow the menu described by sahil. I'm on AS 1.0 too and can see it – kip2 Dec 11 '14 at 09:55
  • 2
    @kip2 It just shows me the project structure, nothing about facets. The + icon adds a new module, not a Facet. All my dependencies are in defined in Gradle build files per module. Maybe it only shows for projects using old versions of Gradle. – G_V Dec 11 '14 at 10:28
  • There should be a facets tab when you go to File > Project Structure – Gerard Feb 15 '15 at 14:12
  • Also can't find Facets in Android 1.1.0 – Ika Feb 26 '15 at 12:11
  • Let me edit this answer and provide you with some screenshots. It must be there, most of us are using Android Studio 1.1.0 – sahil shekhawat Feb 26 '15 at 12:14
  • @lka I have updated the answer, can you try and let me know if this works for you? – sahil shekhawat Feb 26 '15 at 12:36
  • 3
    What if the module is already in the project but it's just not being recognized? – Pkmmte Feb 25 '16 at 01:03
  • 1
    This answer is no longer correct for the newest version of Android Studios. Can someone give us the correct path to *open Module settings*? – Ian Steffy Dec 21 '17 at 15:38
  • 1
    @IanS, strange, but after I made these steps in AS 3.3, I got an empty project. But `Open Module settings` is in place, see https://i.stack.imgur.com/bIPBl.png. – CoolMind Apr 11 '19 at 09:30
50

resolved this issue by clicking on "File->Sync Project with Gradle Files"

Subhasmith Thapa
  • 884
  • 7
  • 11
26

New project. Fixed this issue by clicking on "File->Sync Project with Gradle Files"

upgo
  • 261
  • 3
  • 2
20

I have tried all the options with no luck. So I have ended up with my working solution. Just make following steps:

  1. Close android studio if open.
  2. Copy module(project) in your current workspace.
  3. Start android studio.
  4. You will see added module in project structure.
  5. Open settings.gradle of your project and include ':YOUR_MODULE_NAME'.
  6. Sync gradle and you can see module is successfully added to your project.
Umesh
  • 1,609
  • 1
  • 17
  • 28
16

Try,

Files > Sync Project with Gradle Files or Files > Sync with File System Should do the trick.

Sonic_
  • 347
  • 3
  • 9
15

goto Android >> Gradle Scripts>>Build Gradle(Module :app)

make sure the first line of this file is like this.

apply plugin: 'com.android.application'

not like this

apply plugin: 'com.android.library'
akshay bhange
  • 2,320
  • 2
  • 28
  • 46
13

The following worked for me:

  • edit the overall project's 'settings.gradle' file and add a line at the bottom to include your new module (include ':myNewModule') - e.g:
include ':myNewModule'
  • Synch gradle.
  • Add a build.gradle file into your new module directory. You need to make sure the first line says 'apply plugin: 'com.android.application'. Simply copying a build.gradle from another module in your project, if you have one, seems to work.
  • Synch Gradle
  • Your module should now show up in 'Edit Configurations'
Mick
  • 24,231
  • 1
  • 54
  • 120
10

This mainly happens when you copy a library project and try to build it. The solution would be to add

apply plugin: 'com.android.application'

in the build.gradle file, instead of

apply plugin: 'com.android.library'

Then do a gradle sync

7

This worked for me: File > Project Structure... > Modules > Green Plus Symbol > Import > Then Select The Project

ebeilmann
  • 171
  • 2
  • 6
  • 6 short years later, it was File -> Project Structure -> Modules -> pick a module -> Build Tools Version -> latest version. Now I may have runnable configurations – Phlip Jan 16 '20 at 22:16
5

In your module build.gradle file make sure you have the correct plugin set. it should be

apply plugin: 'android'
Aaron Dancygier
  • 1,996
  • 19
  • 20
5

No configuration was deteched because IDE was unable to detech modules (<no module>).My compileSdkVersion and buildToolsVersion was 28 in build.gradle (app module)

  android {
        .
        .
        compileSdkVersion 28
        buildToolsVersion 28
        .
        .
  }

But SDK was not installed. So then I installed it first and it worked for me !!!

enter image description here

Gk Mohammad Emon
  • 6,084
  • 3
  • 42
  • 42
4

It appears different solutions work for difference people, for me just closing the project and importing it again resolved the problem.

2cupsOfTech
  • 5,953
  • 4
  • 34
  • 57
4

I finally figure out why the module is not showed up when I add configuration for AndroidTests for a com.android.library module.

If you include your library module in your application's build.gradle like this:

compile project(':yourlibrary')

Since for library module it is compiled with release mode by default, you can't run Android Tests for it, that's why it won't show up in the module list. I fixed it with following modification:

Add following configuration to the build.gradle of your library module:

     publishNonDefault true

By make following changes, you can debug compile your library by editing the build.gradle of your application module like following:

-    compile project(':yourlibrary')
+    debugCompile project(path: ':yourlibrary', configuration: 'debug')
+    releaseCompile project(path: ':yourlibrary', configuration: 'release')

Then sync it and you'll find it shows in the list.

xfdai
  • 2,735
  • 1
  • 19
  • 18
4

Android Studio 4+

1- File -> Close project

2- Delete .idea folder

3- Open project again

D.Rosado
  • 5,634
  • 3
  • 36
  • 56
3

It was fixed for me after removing and re-adding the Android and Android-Gradle Facets in the Module Settings dialog.

TalkLittle
  • 8,866
  • 6
  • 54
  • 51
3

I managed to fix it in Android Studio 1.3.1 by doing the following:

  1. Make a new module from File -> New -> New Module
  2. Name it something different, e.g. 'My Libary'
  3. Copy an .iml file from an existing library module and change the name of the file and rename references in the .iml file
  4. Add the module name to settings.gradle
  5. Add the module dependency in your app's build.gradle file 'compile project(':mylibrary')'
  6. Close and reopen Android Studio
  7. Verify that Android Studio recognises the module as a library (should be bold)
  8. Rename module's directory and module name by right clicking on the newly created module.
  9. Enjoy :)
Tim Kist
  • 1,164
  • 1
  • 14
  • 38
3

The following are methods to help you:

  1. Close and Open Project again
  2. Close and Open Android Studio
  3. Clean Project
  4. Rebuild Project
  5. Instantiate and Restart
  6. Make sure you have included :app
  7. Import the Project
jiwopene
  • 3,077
  • 17
  • 30
Vaibhav Kumar
  • 159
  • 1
  • 9
2

I added this line to my app.iml file and it works

orderEntry type="library" exported="" name="appcompat-v7-19.1.0" level="project" />

2

For me it was fixed by simply restarting Android Studio.. Like the good old days of Eclipse

CodeMonkey
  • 11,196
  • 30
  • 112
  • 203
2

In my case problem was from a higher (or not downloaded) compileSdkVersion and targetSdkVersion in build.gradle(app). This was happened because of cloning project in another pc that not downloaded that sdk image.

Mahdi Moqadasi
  • 2,029
  • 4
  • 26
  • 52
1
  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

  5. Project AS project

  6. File -> Sync project with gradle files

David Buck
  • 3,752
  • 35
  • 31
  • 35
user13562154
  • 91
  • 1
  • 1
0

Sometimes the errors exists in Android-manifest because of that there is cross like image over run/debug configuration hence try to look over if Android-manifest has any errors in just case.

KOTIOS
  • 11,177
  • 3
  • 39
  • 66
0

For my case, a newbie I boogered up my project, not sure how but it would not longer run and complained about the manifest, the R, everything. I realized that some how in my settings.gradle did not have include ':app' once I added this, I was back on my way.

JenniferG
  • 602
  • 1
  • 5
  • 13
0

Add your module in your applications .iml file like:

orderEntry type="module" module-name="yourmoudlename" exported="" 

It works for me.

Paritosh
  • 2,097
  • 3
  • 30
  • 42
0

Well, nothing worked for me from all the answers. Finally, I clicked Run > Edit Configuration. On the left, u can choose a new main module and remove to deleted ones.

Sahil Patel
  • 684
  • 7
  • 19
0

If all the above doesn't work. Try to update your Android studio version. Steps: 1. In Android Studio, select File > Settings (or Android Studio > Preference on Mac). 2. In the left pane, select Appearance & Behavior > System Settings > Updates. 3. Be sure that Automatically check for updates is checked, and then select a channel from the drop-down list. 4. Click OK.

Viswesvar Sekar
  • 2,743
  • 3
  • 11
  • 7
0

For me it was:

  1. Right click on app project folder & select Load/Unload Modules...

  2. Select app module, click Unload >, & click OK

  3. Right click on app again & select Load/Unload Modules...

  4. Select app module, click < Load, & click OK

app then appeared for me in the configurations list again.

flopshot
  • 1,153
  • 1
  • 16
  • 23
0

None of the previous answers worked for me, so I deleted and reinstalled Android Studio. Worked like a charm.

Boommeister
  • 1,591
  • 2
  • 15
  • 54
0

In my case the problem was with SDK license acceptance. The problem was solved by downloading proper SDK version and license acceptance via SDK Manager.

Mikhail Sharin
  • 3,661
  • 3
  • 27
  • 36
0

None of the above solutions worked for me.

I just upgraded the version of com.android.tools.build:gradle:7.0.0 in build.gradles to the latest version (currently 7.0.2) and it worked!

upgrading gradle dependency

Pouya Heydari
  • 2,496
  • 26
  • 39
0

Before you import, make sure the project is error-free. In my case, I have to clean and rebuild the project before import.

mhcpan
  • 331
  • 3
  • 7
0

Also, try this that worked for me:

  • Close all projects.
  • From the wizard click on Plugins
  • Look for Gradle and click on "Enable all"
  • Go back to the Projects tab and click on your project
-2

These types of problems are related to AndroidManifest.xml, so check the bugs thats are in AndroidManifest file.

NEERAJ GUPTA
  • 125
  • 1
  • 11