59

I am importing a library module named "wear" in my project and while building, I am getting this:

Error : A problem occurred configuring project ':app'.   
Could not resolve all dependencies for configuration ':app:_debugApk'.   
Project :app declares a dependency from configuration 'compile' to configuration 'default' which is not declared in the descriptor for project :wear.

What does it mean? How can I get rid of this?

SapuSeven
  • 1,473
  • 17
  • 30
ruhulrahat
  • 1,325
  • 4
  • 15
  • 23
  • Could you solve this yet? I am facing the same issue while building for React Native through Android Studio. – kittu88 Mar 23 '17 at 15:59
  • Are you using composite builds? I have this error when I build with `--include-build`, but without it I have another one: `Could not find libmylib.aar (com.package:libmylib:1.0-BETA-SNAPSHOT). Searched in the following locations:`, even though the "location" in which it searches is the right link. In my case, I get those errors with gradle 3.4.1, but not with gradle 2.14.1 (i.e. the latter works fine). – JonasVautherin Mar 31 '17 at 15:13
  • @rarahat02, Did you found any solution for this issue. Am also facing the same issue. If so, please suggest the possible way to fix the issue. – Senthil Mg Jun 07 '17 at 11:45
  • not yet @SenthilMg – ruhulrahat Jun 07 '17 at 14:50
  • one of the reasons for this problem is renaming directory name for the module. so don't change folder of your modules – Rajesh N Oct 15 '17 at 05:21

11 Answers11

38

This error usually occurs when Gradle cannot find a particular component. I experienced this when trying to use the Salesforce React Native Android example.

The error message you get looks like the one you posted ... in my case it was

Project :app declares a dependency from configuration 'compile' to configuration 'default' which is not declared in the descriptor for project :libs:SalesforceReact.

I found my Gradle settings file ( called settings.gradle ) in the projects android directory. The start of it looked like this

rootProject.name = 'SmartSyncExplorerReactNative'

def libsRootDir = new File( settingsDir, '../node_modules/SalesforceMobileSDK-Android/libs' )
include ':app'

include ':libs:SalesforceReact'
project( ':libs:SalesforceReact' ).projectDir = new File( libsRootDir, 'SalesforceReact' )

In this case, the path given in libsRootDir did not exist (as these libraries actually came from a different repository which I cloned and then pointed this path to!).

Once I had corrected the path, save the settings file and reran, everything worked smoothly.

I hope this helps, Jonathan.

Jonathan Dawson
  • 551
  • 5
  • 5
  • 1
    This just happened to me and thanks to your answer I found that the npm module I was pointing to in the path was not installed! Thanks! – Joshua Dyck Aug 30 '17 at 00:23
15

I have faced same issue when i update android studio 3.0 and following solutions works for me

implementation project(path: ':yourModule', configuration: 'default')

This solution will work if you are using Gradle 4.1 and above and Gradle Plugin Version 3.0.0 and above.

I hope this will work for you

Saurabh Bhandari
  • 2,438
  • 4
  • 26
  • 33
  • For some more info about why this fix works see this answer: https://stackoverflow.com/questions/33718663/gradle-error-configuration-declares-dependency-which-is-not-declared – bmul Dec 07 '17 at 15:22
5

I found this error too. So, I noticed that my settings.gradle was searching for a path that didn't exist. Example: (settings.gradle)

project(':YourProjectV1').projectDir = new File('../YourProjectFolderV1/app/');

However, in my filesystem, the path was: ../YourProjectFolderv1

After syncing the names, the project was ok!

I hope that helps.

Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
Ramon Costa
  • 59
  • 1
  • 1
4

I ran into a similar issue with a different set of modules. I was finally able to resolve it by reinstalling the necessary modules via npm but with the --save flag. i.e. npm install --save module-name

It looks like if you just have the .iml file in the module folder, it's not enough for the android studio to resolve it.

Good luck.

Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
2

Actually the project itself lays inside the target project root folder:

...
 |-wear
      |-app

So in order to include it properly you have to define path that points to that inner folder:

'setting.gradle':

include ':app', 'MyLibraryProject'
project(':MyLibraryProject').projectDir = new File("X:\\SOME_PATH\\wear\\app")

'app\build.gradle' (Main project)

dependencies {
...
compile project(':MyLibraryProject')
...
}
Yan
  • 1,569
  • 18
  • 22
0

I ran into this errors too, it turns out that there are a library path changed. Im using react-native-maps version 1.4

In settings.gradle change the react-native-maps dependency path to

... include ':react-native-maps' project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')

It seems to me the installation manual is not updated

indrasantosa
  • 101
  • 2
  • 3
0

I recently encountered such a problem, when I was in the window10 compiler no problem, but I compiled a problem in Linux, I think this reason with the platform, I checked and found that my project name is with the case Named, and then I unified named lowercase letters, and then build, found successful. ^ _ ^.

0

for me, I just modify the line in settings.gradle: project(':test').projectDir = new File(rootProject.projectDir, '~/android-test') to project(':test').projectDir = new File(rootProject.projectDir, '/Users/Michael/android-test') which means avoid using "~" in the settings.gradle.

Michael
  • 646
  • 6
  • 16
0

I actually just needed to add the submodule so I ran the following git commands in terminal:

git submodule init git submodule update and then a rebuild!

Blaze Gawlik
  • 337
  • 3
  • 11
-1

first: rm -rf node modules

then: npm i

then: Build -> Clean

then: Close Android Studio and Reopen. This time u should be promoted in the bottom area that react-native-maps needs to be installed. Click on the link and install it

SleepsOnNewspapers
  • 3,353
  • 3
  • 23
  • 29
-3

This case is you don`t install the plugin.Please you install the plugin.Such as "npm install -s wear"