65

I am using Android studio and I want to add module to my project like "action bar Sherlock" or jar files, but when I opened the project structure there is no module or library in the menu :\

In intelij it's appearing:

enter image description here

So what's the problem? How can I add these modules in Android studio?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Mohamd Ali
  • 2,146
  • 4
  • 23
  • 30

19 Answers19

62

Update 19 March 2019

A new experience someone has just faced recently even though he/she did add a library module in app module, and include in Setting gradle as described below. One more thing worth trying is to make sure your app module and your library module have the same compileSdkVersion (which is in each its gradle)!

Please follow this link for more details.

Ref: Imported module in Android Studio can't find imported class

Original answer

Sometimes you use import module function, then the module does appear in Project mode but not in Android mode

enter image description here

enter image description here So the thing works for me is to go to Setting gradle, add my module manually, and sync a gradle again:

enter image description here

Nguyen Tan Dat
  • 3,780
  • 1
  • 23
  • 24
  • 6
    even if you already have it inside the settings.gradle file , delete it and add it again at a different place (the end of file for example so that android detect a change in the file ) then sync gradle – Mohammed Fathi Nov 24 '20 at 11:54
18

First, create your Module. You can do that using the default Android Studio Module Wizard (File -> New -> New Module), select Android Library, give it a Name and a package name, and finish. After that you will see that nothing happens. Open the side Gradle Projects Section (should be somewhere on the right panel)

You should see something like this:

enter image description here

Expand your module gradle and run the Run Configurations task. After that refresh the content and refresh the project structure.

It should work now.

Aurelian Cotuna
  • 3,076
  • 3
  • 29
  • 49
11

Do right mouse click on your project, then select 'Open Module Settings' - then you can add modules to your project..

Jis Jose
  • 614
  • 1
  • 6
  • 15
  • 2
    I don't see how I can use this to add modules that are in the directory though? I only see ways to add new modules.. – AdamMc331 Dec 11 '15 at 23:19
  • Thanks in android studio 2.3.3 I don't know what happened it was first in project structure – Pulkit Jul 19 '17 at 03:41
10

Go to File->Project Structure-> Project Settings -> Modules.

Click on the green colored + and add new module. select Application module and set the content root to your project module.

Click next and then finish.

Reference

Community
  • 1
  • 1
Darpan
  • 5,623
  • 3
  • 48
  • 80
  • This is very helpful post. I have one correction, that is : After selecting my project, it saying "app" already in project. In that case i added as "app1" and click ok. After that IDE shows both module "app" and "app1". Then i deleted "app1" from project structure and run project after selecting "app" module. Then it works very well. – Md. Sajedul Karim Aug 04 '17 at 08:59
9

I had the same problem, after switching to a branch that did not have my module, then switching back.

Clean Project -> Rebuild Project did not work for me.

But File -> Invalidate caches/restart did work.

SnuKies
  • 1,578
  • 1
  • 16
  • 37
8

You need to add a gradle.settings file to your root project structure, after that when you "Open Module settings" you will the menu aligned to your gradle.settings. When importing a project to Android Studio, it doesn't create this file for you. Sometimes it's usually better to start a clean project and move your code there, it's usually easier to achieve.

maraujop
  • 4,472
  • 2
  • 36
  • 40
7

This Might be help some:

To import module as library in your project.

  1. File > New > Import Module
  2. Select Valid path in Source Dir..
  3. Tick on Import > Finish

Now Open Module setting:

  1. Go to File > Project Structure > Modules
  2. Modules > Dependency > click on Green Plus Sign.
  3. Click on Module Dependency > locate module > and Implement your module.

if your module is not shown in "Choose Modules Window"

Follow the below step..

  1. Open Settings.Gradle file
  2. include ':app', 'Put your module name here' and sync project.

Follow Open Module Setting as above.

Bhavesh Moradiya
  • 1,323
  • 14
  • 18
7

As for me issue was that the first line in the build.gradle file of the OpenCV library.

It was something like this: apply plugin: 'com.android.application' This refers to the fact that the imported OpenCV is an application and not a library. It exists for OpenCV above 4.1.0. So change it to: Something like this: apply plugin: 'com.android.library'.

You might get an error in ApplicationId, comment it out in the gradle file.

Beeti Sushruth
  • 321
  • 2
  • 12
6

Open settings.gradle and add the module as below,

include ':app',':bottomnav'

here i have added my newly imported module ':bottomnav' separated with a comma. then Sync your project. your module will be visible to dependency. Android Studio only displays those module, which are defined in the settings.gradle file of your application. after defining the module in settings.gradle, you will be able to add the module as dependency of your application.

Kiran Maniya
  • 8,453
  • 9
  • 58
  • 81
5

Check settings.gradle. You'll find this : include ':app'

Just add your own module name and it should look like this :

include ':app', ':yourModuleName'

Sync.

That's it.

Tuhin Subhra
  • 356
  • 5
  • 17
3

Had similar issue when running version control on a project in Android Studio (0.4.2). When pulling it down to a new location and importing the modules, only the "Android SDK" were showing in the Project Structure.

I removed the .idea/ folder from the version control, by adding it to .gitignore file, and did a fresh pull and imported the modules. Now all the settings appeared correctly in the Project Settings and Platform Settings for the Project Structure.

Priebe
  • 4,942
  • 3
  • 24
  • 38
  • 1
    Modules were added and pushed from a machine, then pulled from a 2nd machine, but here they were not visible as module. Deleting folder .idea made regenerating the workspace.xml – Davideas Jul 28 '15 at 09:58
3

Here's what I did to solve this problem

  • Close Android Studio
  • Quick Start -> Check out from Version Control
Lucas
  • 6,675
  • 3
  • 25
  • 43
  • 1
    I don't understand. Where is quick start and what version control? – Yster Aug 08 '14 at 20:51
  • Quick Start is the window that shows up when you launch Android Studio – Lucas Aug 10 '14 at 15:07
  • 1
    What Lucas means was Click on File > Close project. And after that a window opens which is called Quick Start and do as Lucas says. – Pulkit Jul 19 '17 at 04:02
2

Please go to Module settings and choose Modules from Project Settings then you need to Select src and gen folders and marked them as Source folders by right-click on them and select Source

Mahmoud M
  • 59
  • 1
  • 8
1

First You Have To Add Name Of Your Module In setting.gradle(Project Setting) File Like This..

include ':app', ':simple-crop-image-lib'

Then You Need To Compile This Module Into build.gradle(Module app) File Like This..

implementation project(':simple-crop-image-lib')
    

That's all for adding module now it will be appear in android section or project section as well.

If It's till did't appear rebuild or clean your project..

Boken
  • 4,825
  • 10
  • 32
  • 42
Bhavik Nathani
  • 470
  • 5
  • 13
1

Although not similar to the question above,

In my case, The module is not visible in the android tab, I saw it in the project tab.

After deleting the .idea/workspace.xml file, (I guess there is a problem because the unloadlist list remains here?) When I reopened the project, it worked fine.

Additionally, When invalidate caches (clear VCS Log caches and indexes), It shows up for new modules, not for previously deleted modules (this only worked when deleting workspace.xml).

unemployer
  • 158
  • 7
  • This problem seems to occur when you right-click a module in the ide and then unload module. – unemployer Sep 27 '22 at 05:12
  • This fixed my issue. Not only was it not visible in the Android structure, it was visible in the Project structure, however it was erroring out in my code space. Everything was building correctly and module was properly set in all areas, but the imports in the file heads were failing to find the module. The above solution is the only thing that worked for me. – Bryan Neuberger Jan 03 '23 at 16:40
0

If you moved the modules, modify your workspace.xml file and settings.gradle file to use the new paths of your module. Otherwise you will need to try using the import module feature.

Pellet
  • 2,254
  • 1
  • 28
  • 20
0

Make sure the directory name is lower case.

IAmCoder
  • 3,179
  • 2
  • 27
  • 49
0

First and foremost, check that all the modules are listed in your settings.gradle file.

  • If they are not, add them.

  • If they are, change something/anything in the file so that the Sync Project prompt comes on. Sync and your project should compile fine; the modules you're looking for will appear in your project structure.

Taslim Oseni
  • 6,086
  • 10
  • 44
  • 69
-1

in my case somehow build.gradle file deleted under app i restore it

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 31 '21 at 10:20