Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle error: configuration declares dependency which is not declared

I'm making my first android wear app, but I can't get Android Studio working. First I got the error

 "Project with path ':wear' could not be found in project ':mobile'.  

This was resolved by adding "include ':wear" in settings.gradle.
But then a new error occurs:

"Error:Module version Test2:mobile:unspecified, configuration 'wearApp' declares a dependency on configuration 'default' which is not declared in the module descriptor for Test2:wear:unspecified" . 

What do I have to do to resolve that error?

Just in case it's needed: here's build.gradle:

apply plugin: 'com.android.application'  android {     compileSdkVersion 23     buildToolsVersion "23.0.2"      defaultConfig {         applicationId "com.verbraeken.joost.test2"         minSdkVersion 19         targetSdkVersion 23         versionCode 1         versionName "1.0"     }     buildTypes {         release {             minifyEnabled false             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'         }     } }  dependencies {     compile fileTree(dir: 'libs', include: ['*.jar'])     wearApp project(':wear')     testCompile 'junit:junit:4.12'     compile 'com.android.support:appcompat-v7:23.1.1'     compile 'com.google.android.gms:play-services:8.3.0'     compile 'com.android.support:design:23.1.1' } 

settings.gradle:

include ':mobile' include ':wear' 
like image 793
Joost Verbraeken Avatar asked Nov 15 '15 10:11

Joost Verbraeken


People also ask

What is Gradle dependency configuration?

What are dependency configurations. Every dependency declared for a Gradle project applies to a specific scope. For example some dependencies should be used for compiling source code whereas others only need to be available at runtime. Gradle represents the scope of a dependency with the help of a Configuration.

How do I add a dependency in Gradle?

To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build.gradle file.


1 Answers

In Android Studio 3.0 the documentation for Migrate to the New Plugin says:

dependencies {     // This is the old method and no longer works for local     // library modules:     // debugCompile project(path: ':foo', configuration: 'debug')     // releaseCompile project(path: ':foo', configuration: 'release')      // Instead, simply use the following to take advantage of     // variant-aware dependency resolution. You can learn more about     // the 'implementation' configuration in the section about     // new dependency configurations.     implementation project(':foo')      // You can, however, keep using variant-specific configurations when     // targeting external dependencies. The following line adds 'app-magic'     // as a dependency to only the 'debug' version of your module.      debugImplementation 'com.example.android:app-magic:12.3' } 

So change this

    debugCompile project(path: ':foo', configuration: 'debug')     releaseCompile project(path: ':foo', configuration: 'release') 

to this

    implementation project(':foo') 
like image 133
Jonas Borggren Avatar answered Sep 22 '22 13:09

Jonas Borggren