Android Studio: Module won't show up in "Edit Configuration"
Asked Answered
D

36

246

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?

Davisson answered 21/8, 2013 at 22:26 Comment(2)
Hi Did you ever solve this issue i'm getting exactly the same issue.Liner
Could this help, solved my problem like yoursFricative
P
166

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

Perfuse answered 7/9, 2014 at 12:47 Comment(5)
That fixed my issue! Only synced with gradle again and AS recognized it.Uzzi
I'm looking for this answer since 1hDiscourage
For me just clicking the "Sync Project with Gradle Files" fixed it. I was really worried I had busted things beyond repair.Catacomb
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.Unpaidfor
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.Smetana
W
95

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.

Wain answered 22/1, 2014 at 22:48 Comment(10)
This fixed my problem! Thanks! Just had to close the project and import the gradle file again.Pop
Thank you, it worked. Android Studio is as annoying as ever.Ml
closing and importing worked for me also. But not sure what is the root cause, at the first placeBergius
closing project and then just restarting android studio did work for me. thank you guys.Shayneshays
I can't believe this is how a very big problem solved!Lauderdale
i cant seem to find "Delete Projecdt from Android Studio" option on the newest version of ASToponym
@thagr You can try closing the project, then deleting/renaming the ".idea" folder (in the same folder as the build.gradle file).Marigolde
This worked for me up until the part about selecting the build.gradle file. All I had to select was the root project folder, and it worked!Acquire
You can "Delete Project from Android Studio" by simply clicking the "X" next to the project name in the startup windowAcquire
Thanks this solves the problem for Android 4.1.1Approval
D
77

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. :)

Disclaimer answered 11/10, 2018 at 7:18 Comment(4)
Works also on 3.3.1Bevash
@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.Discombobulate
should be the ACCEPTED answer. +1Savoirvivre
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.Lacewing
A
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).

Ameba answered 26/6, 2014 at 15:3 Comment(10)
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.0Danie
@Danie 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 itPhenix
@Phenix 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.Danie
There should be a facets tab when you go to File > Project StructureHalfsole
Also can't find Facets in Android 1.1.0Saguaro
Let me edit this answer and provide you with some screenshots. It must be there, most of us are using Android Studio 1.1.0Ameba
@lka I have updated the answer, can you try and let me know if this works for you?Ameba
What if the module is already in the project but it's just not being recognized?Agile
This answer is no longer correct for the newest version of Android Studios. Can someone give us the correct path to open Module settings?Eam
@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 i.stack.imgur.com/bIPBl.png.Discombobulate
D
51

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

Disclosure answered 21/1, 2019 at 7:29 Comment(1)
I wish I could upvote everytime I come here, thanks so muchLinsang
N
26

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

Nucleoprotein answered 26/8, 2019 at 2:57 Comment(1)
There's no such option when I click fileEgesta
A
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.
Anatol answered 7/10, 2015 at 6:16 Comment(1)
Open settings.gradle of your project and include ':YOUR_MODULE_NAME' Worked for me THx.Girardi
F
16

Try,

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

Formerly answered 5/12, 2018 at 4:56 Comment(1)
Have you read the previous comments? Is there any sense to duplicate the right answer?Marienthal
F
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'
Fingerbreadth answered 15/1, 2015 at 11:33 Comment(0)
T
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'
Tachistoscope answered 28/12, 2016 at 12:31 Comment(2)
module (include*,* ':myNewModule') Missing a commaEam
I don't think a comma is needed there in cradle settings - I've added in a specific example.Tachistoscope
L
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

Lessard answered 28/11, 2016 at 19:38 Comment(1)
Several people have already added this solution to this question.Comber
B
7

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

Beauvais answered 3/9, 2014 at 20:22 Comment(1)
6 short years later, it was File -> Project Structure -> Modules -> pick a module -> Build Tools Version -> latest version. Now I may have runnable configurationsContraceptive
B
6

Android Studio 4+

1- File -> Close project

2- Delete .idea folder

3- Open project again

Bagehot answered 10/6, 2021 at 8:53 Comment(0)
I
5

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

apply plugin: 'android'
Impellent answered 16/5, 2014 at 23:29 Comment(0)
H
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

Haematoxylon answered 15/3, 2021 at 4:53 Comment(0)
N
4

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

Negress answered 24/9, 2014 at 16:28 Comment(0)
V
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.

Vitrine answered 18/1, 2017 at 7:1 Comment(2)
please explain what is "yourlibrary"?Buryat
@ZiaUrRahman yourlibrary is the module name of your library moduleVitrine
B
3

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

Binford answered 7/10, 2013 at 15:46 Comment(1)
Similar for me. Removed and re-added the module themselves. Then it worked.Unseam
V
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 :)
Varico answered 12/8, 2015 at 15:22 Comment(0)
S
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
Stereobate answered 15/1, 2020 at 18:57 Comment(0)
E
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" />

Edmead answered 23/6, 2014 at 13:42 Comment(0)
C
2

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

Chickadee answered 16/7, 2017 at 12:1 Comment(0)
N
2
  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

Nunnally answered 17/6, 2020 at 6:36 Comment(0)
T
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.

Tyler answered 21/10, 2020 at 21:29 Comment(0)
T
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.

Transitive answered 4/11, 2015 at 9:42 Comment(0)
A
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.

Abeu answered 6/2, 2016 at 12:32 Comment(0)
R
0

Add your module in your applications .iml file like:

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

It works for me.

Romberg answered 20/4, 2018 at 7:54 Comment(1)
Can you format your answer? This might help.Barney
C
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.

Colonial answered 27/5, 2018 at 10:40 Comment(0)
G
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.

Gramme answered 22/5, 2019 at 20:57 Comment(0)
B
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.

Bettis answered 5/6, 2019 at 21:1 Comment(0)
T
0

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

Thaumaturgy answered 14/11, 2020 at 6:59 Comment(0)
P
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.

Pyrite answered 21/12, 2020 at 9:2 Comment(0)
F
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

Faires answered 2/10, 2021 at 9:50 Comment(0)
A
0

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

Augmentation answered 4/7, 2022 at 8:18 Comment(0)
T
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
Tillich answered 29/1, 2023 at 20:12 Comment(0)
G
-2

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

Goniometer answered 3/2, 2016 at 5:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.