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'.
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'
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.