Ryan R
Ryan R

Reputation: 8461

Unable to find module with Gradle path. Linking to library -unspecified instead

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')

Upvotes: 37

Views: 31129

Answers (11)

Farhan Ar Rafi
Farhan Ar Rafi

Reputation: 148

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

Upvotes: 0

Diego Rodrigues
Diego Rodrigues

Reputation: 31

I had this problem and solved it by clicking on

File> Ivalidate cache / Restart...

as shown below:

print android Studio

Upvotes: 3

Wojtek Dmyszewicz
Wojtek Dmyszewicz

Reputation: 4318

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

Upvotes: 3

Hossein Rashno
Hossein Rashno

Reputation: 3469

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

Upvotes: 3

Maxim M
Maxim M

Reputation: 336

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

Upvotes: 4

Michael
Michael

Reputation: 666

  1. delete the .iml file under the error module.
  2. restart Android studio

Upvotes: 13

Willi Mentzel
Willi Mentzel

Reputation: 29884

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.

Upvotes: 0

ahasbini
ahasbini

Reputation: 6901

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.

Upvotes: 54

Varun Bhatia
Varun Bhatia

Reputation: 4396

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

Upvotes: 9

Hua
Hua

Reputation: 51

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.

Upvotes: 5

Avi Shukron
Avi Shukron

Reputation: 6118

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.

Upvotes: 3

Related Questions