3

I am adding Firebase to an existing app with 3 buildTypes (debug, staging and release). There's also 2 flavors (live and mock), but I am enabling mock only for debug builds:

android.variantFilter { variant ->
    if ((variant.buildType.name.equals('release') || variant.buildType.name.equals('staging'))
            && ((variant.getFlavors().get(0).name.equals('mock')))) {
        variant.setIgnore(true);
    }
}

So there are 3 applicationIds: me.app (release), me.app.debug(debug) and me.app.staging (staging). As evident, there's only one app for debug, although there are 2 variants (debugLive and debugMock)

On Firebase, I created 1 project and added 3 apps - 1 for each application ID. I did not give a SHA1 key for any of these apps as of now. I downloaded the google-services.json and placed it in the base-feature module's root directory.

I am unable to sync project with Gradle now:

More than one variant of project :myapp-base-feature matches the consumer attributes:
  - Configuration ':myapp-base-feature:mockDebugApiElements' 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 'mockDebug' but wasn't required.
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      - Required mocking 'mock' and found compatible value 'mock'.
      - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
  - Configuration ':myapp-base-feature:mockDebugApiElements' 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 'mockDebug' but wasn't required.
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      - Required mocking 'mock' and found compatible value 'mock'.
      - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
  - Configuration ':myapp-base-feature:mockDebugApiElements' 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 'mockDebug' but wasn't required.
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      - Required mocking 'mock' and found compatible value 'mock'.
      - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
  - Configuration ':myapp-base-feature:mockDebugApiElements' 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 'mockDebug' but wasn't required.
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      - Required mocking 'mock' and found compatible value 'mock'.
      - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
  - Configuration ':myapp-base-feature:mockDebugApiElements' 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 'mockDebug' but wasn't required.
      - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
      - Required mocking 'mock' and found compatible value 'mock'.
      - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
BadCode
  • 259
  • 3
  • 12

1 Answers1

3

Downgrade your Google Service to 3.2.1 it is a known bug with flavors and submodules for 3.3.1 at least, probably 3.3.+

  dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.31"
        classpath 'com.google.gms:google-services:3.2.1' 
        classpath 'io.fabric.tools:gradle:1.25.4'
    }
Sam
  • 5,342
  • 1
  • 23
  • 39
  • Can you please share a link to issue tracker? This will help us move to the latest version in the future. – BadCode Jun 04 '18 at 22:59
  • Sorry, I ran into it almost a month ago now and I did not save the link. I'm not sure of the link anymore. Took a lot of Googling to find the issue to begin with. I am certain of the problem and the fix, but not certain of the issue tracking number or ETA on resolution. Hopefully in their next patch. Wish I could point you there, but can't find it now, so you will have to do some poking through Google to run into it. – Sam Jun 05 '18 at 19:31