25

Edit: Seems to be a bug on Google side. Bug report here: https://issuetracker.google.com/issues/79235243


Since Google released the new changes (), I had to update google services. Once I did, I get this gradle error:

More than one variant of project :myModule matches the consumer attributes:
  - Configuration ':myModule:debugApiElements' variant android-aidl:
      - Found artifactType 'android-aidl' but wasn't required.
      - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
      - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
  - Configuration ':myModule:debugApiElements' variant android-classes:
      - Found artifactType 'android-classes' but wasn't required.
      - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
      - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
  - Configuration ':myModule:debugApiElements' variant android-manifest:
      - Found artifactType 'android-manifest' but wasn't required.
      - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
      - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
  - Configuration ':myModule:debugApiElements' variant android-renderscript:
      - Found artifactType 'android-renderscript' but wasn't required.
      - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
      - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
  - Configuration ':myModule:debugApiElements' variant jar:
      - Found artifactType 'jar' but wasn't required.
      - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
      - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.

Here is the Project's build.gradle:

buildscript {
  repositories {
    google()
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
    classpath 'com.google.gms:google-services:3.3.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
}

allprojects {
  repositories {
    google()
    jcenter()
    maven{
      url 'https://oss.sonatype.org/content/repositories/snapshots/'
    }
    maven {
      url "https://maven.google.com"
    }
    maven { url "https://jitpack.io" }
  }
}
Sree
  • 2,727
  • 3
  • 29
  • 47
  • Can you please post ```myModule``` build.gradle? – sha May 04 '18 at 03:50
  • 1
    It seems to be an issue coming from the latest com.google.gms:google-services:3.3.0 library. They probably haven't tested it with projects with more than one module. – user1940676 May 04 '18 at 10:22
  • This happened due to https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html. – Thuy Trinh May 04 '18 at 10:56

2 Answers2

13

I had exactly the same issue and found the answer to be to change the syntax of the offending module reference as follows:

Previous Implementation:

compile project(':myModule')

Current Implementation:

compile project(path: ':linkedin-sdk', configuration: 'default')

thanks...

Thanks to https://github.com/dialogflow/dialogflow-android-client/issues/57

SkyWalker
  • 28,384
  • 14
  • 74
  • 132
user3621075
  • 343
  • 2
  • 11
5

I did not update the services, but I got the same problem. I spent 5 hours looking for a solution. Fixed only this way.

Try to set

classpath 'com.google.gms:google-services:3.2.1'

instead of

classpath 'com.google.gms:google-services:3.3.0'

It's helped in my case, but I don't know the cause of the error.

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59
Zeon
  • 535
  • 8
  • 23
  • 3
    Yea that works but I was hoping to not downgrade. Do you think it's a bug on their end? – Sree May 04 '18 at 05:24
  • 98% i don't change my code, It should work, but it's not – Zeon May 04 '18 at 05:31
  • This resolved the issue for me. It seems that 'com.google.gms:google-services:3.3.0' and 'com.google.gms:google-services:3.3.1' may have a bug or a changed interface that has not been explained. – user3621075 May 09 '18 at 10:29
  • 1
    bug report here incase you were looking for it: https://issuetracker.google.com/issues/79235243 – Sree May 09 '18 at 20:51
  • 2
    `classpath 'com.google.gms:google-services:4.0.1'` works for me – Steve Strates May 24 '18 at 20:32
  • @SteveStrates Thank you. The same worked for me after searching for 3hrs. Your find helped me too. – Eswar Jul 27 '18 at 14:14