37

Update 2 This has been fixed in Android Studio 1.2 Beta 3

Update: This has reportedly been fixed in an upcoming release of Android Studio.

In Android Studio 1.2 Beta 2 I started getting the following warnings when syncing Gradle.

Failed to set up dependencies
Warning:Unable to find module with Gradle path ':Library1'. Linking to library 'Library1-unspecified' instead.
Warning:Unable to find module with Gradle path ':Library2'. Linking to library 'Library2-unspecified' instead.

I've noticed that jumping to a declaration declared in one of the library modules pulls up the Decompiler instead of just going to the actual source in the library module.

In my Android Studio Project I have the following modules:

- App
- Library1
- Library2

Module: App build.gradle snippet:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':Library1')
    compile project(':Library2')
}

settings.gradle file:

include ':App'
include ':Library1'
include ':Library2'
project(':Library1').projectDir = new File(settingsDir, '../library1/lib')
project(':Library2').projectDir = new File(settingsDir, '../Library2/lib')
2
  • I just ignored them. Cmd + F9 rebuilds the project with no problems. Commented Apr 10, 2015 at 18:01
  • This specific issue is being addressed in an update to Android Studio. I'll post an answer once it is released.
    – Ryan R
    Commented Apr 10, 2015 at 20:45

11 Answers 11

54

I faced this with Android Studio 2.2.3. The problem was with the .iml file that was causing the problem.

After importing the module folder into the project directory and adding the changes to include module in settings.gradle, delete the .iml file from the module folder and do a Gradle Sync. Then right click on any module in the Project Window and click on "Configure Project Subset...", if the imported module is not checked, check it and Android Studio should do a Gradle Sync. By then the imported module will appear in the Project Window and will have a .iml file regenerated that is does not cause any issues.

5
  • 15
    Close Android Studio. And I deleted all the *.iml and the .idea folder in my FileExplorer/FileSystem. Sync the project, then solved. My Android Studio is v2.3.1.
    – imknown
    Commented Apr 16, 2017 at 4:37
  • @ahasbini no, i just do as kimu said
    – hoot
    Commented May 3, 2017 at 12:38
  • 5
    Still a problem on 3.0 and 3.1 :(
    – nmr
    Commented Nov 14, 2017 at 22:38
  • Could you provide with more details? Did you try the above suggested solutions? Probably should open a new question...
    – ahasbini
    Commented Nov 14, 2017 at 23:22
  • Thank you! I was banging my head against the wall for HOURS and Gradle wouldn't stop complaining that it couldn't find the module even though the module was clearly there. This saved my butt. Thank you so much!
    – th317erd
    Commented May 31, 2018 at 1:09
12
  1. delete the .iml file under the error module.
  2. restart Android studio
2
  • Yes, this should be the accepted answer - plain and simple.
    – b005t3r
    Commented Sep 19, 2018 at 10:24
  • Thanks, This helped me to resolve the issue but gradle took long time to sync when we delete .iml files. Wish u patience.
    – A2N
    Commented Sep 24, 2019 at 6:16
9

Right click project, Select "Configure Project Subset ..." and select your module, rebuild your project.

2
  • Thanks, this solution works on AS 2.1.1 after some unspecified problem with import library module
    – mtrakal
    Commented Jun 8, 2016 at 11:32
  • dunno about right click. but cmd+shift+A will help you find this menu option
    – Defuera
    Commented Feb 6, 2018 at 10:48
5

I met the same problem on AS 2.0 preview, and I fixed it by following steps:

1.Rename the module. 2.Change the names in app/build.gradle and setting.gradle. 3.Start gradle sync.

I don't know why but it works on my issue.

1
  • 2
    sounds like a cache issue but i invalidated cache and restarted and didn't fix it. Commented Aug 10, 2016 at 13:07
4

Check in settings. of your app. Down there is the field "Load/Unload Modules"

Your module might be unloaded, that's why Android Studio ignores it even if you specify it in Gradle.

At least that was the problem for me.

enter image description here

3

It is a known bug introduced in 1.2 Beta 2.

See This issue on the Android issue tracker. Fix should be out within hours.

4
  • Thanks. Yes Android Studio 1.2 Beta 3 fixes this issue.
    – Ryan R
    Commented Apr 11, 2015 at 1:02
  • The issue is resolved here: code.google.com/p/android/issues/detail?id=163888
    – Ryan R
    Commented Apr 11, 2015 at 1:05
  • 2
    I have Android Studio 1.4 RC 3 but issue is still there
    – Zeeshan
    Commented Sep 28, 2015 at 19:16
  • 6
    This seems to have re-surfaced in Android Studio 3.0. Been unable to have this working since Canary 3. Tested again on Beta 2
    – Marchy
    Commented Aug 15, 2017 at 16:12
3

If you are using React-native>60, then you should run npx jetify on root of your project before doing Gradle sync.

1
  • This was very useful. Handled my issue. Commented Dec 17, 2019 at 15:34
3

For me the following worked in Android Studio 3.5.3

First of all, check if the path is correct in your Gradle settings.

If the path is correct then invalidate caches & restart by navigating to the top 'File' menu

1
  • I just did a re-sync. Little faster than invalidating caches and restarting ... lots o re-indexing. In my case it happens every time I open Android Studio. I think it is because I have a module that is shared with an Intellij Java gradle project. Have not figured out what one does to the other. The error is one way. Once it works in Android Studio opening the Intellij project has no problem. Commented Feb 12, 2020 at 20:14
3

I had this problem and solved it by clicking on

File> Ivalidate cache / Restart...

as shown below:

print android Studio

0

Problem:

This problem can also occur when you change the path to the module.

settings.gradle

include ':app', ':filechooserlibrary'
project(':filechooserlibrary').projectDir = new File('../../repos-github/file-chooser/file-chooser-library/filechooserlibrary')

I changed the path to '../../github/file-chooser/file-chooser-library/filechooserlibrary'

The old path did not exist any more. But then, instead of accepting the new path, Android Studio recreated the old path structure thus referring to an empty directory.

Solution: So, I deleted this obsolete path structure and restarted Android Studio, after deleting the .iml file (I don't know if this is necessary, but it cannot do harm). Then I reimported the Gradle project and it worked.

0

Try using an updated version of NDK.

I faced the same issue. I was using NDK version r17c. Issue solve after using r21e.

  • Android Studio Version: 4.1.3
  • OS: Ubuntu 18.04.5

Not the answer you're looking for? Browse other questions tagged or ask your own question.