I have written a custom library
gsp-library
which uses RemoteMessage from Firebase. My main app also uses Firebase for checking crush issue and so on.
Environment:
gradle 4.7
java 8
Exception:
More than one variant of project :gsp-library matches the consumer attributes How to fix it? Any kind of help will be highly appreciated.
project.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.3.0'
}
}
allprojects {
repositories {
...
}
}
app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.beauty.app"
minSdkVersion 19
targetSdkVersion 27
versionCode 12
versionName "1.12"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
// Keep the following configuration in order to target Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-gcm:12.0.1'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.firebase:firebase-crash:12.0.1'
implementation project(":gsp-library")
}
apply plugin: 'com.google.gms.google-services'
gsp-library.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode 12
versionName "1.12"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
}
Error comes from both following command:
beautyApp\gsp-library> gradle clean assembleDebugbeautyApp\app> gradle clean assembleDebug
Exception:
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:
- Configuration ':myModule:debugApiElements' variant android-manifest:
- Configuration ':myModule:debugApiElements' variant android-renderscript:
- Configuration ':myModule:debugApiElements' variant jar:
Root Cause Analysis:
The google-services gradle plugin is made to work with Google Play Services and Firebase 15+, but you're using it with version 12.0.1.
Solution#1:
There is a known bug with Google services 3.3.0.
Either use the 4.0.1 version which fixes the bug or downgrade to 3.2.1
Try to set
classpath 'com.google.gms:google-services:3.2.1'
instead of
classpath 'com.google.gms:google-services:3.3.0'
Resource Link:
https://stackoverflow.com/questions/50132601/gradle-more-than-one-variant-of-project-mylib-matches-the-consumer-attributes
No comments:
Post a Comment