3

I know this question has been asked many time but I couldn't figure this out. Let me explain on 2 may firebase has announced that Firebase Android SDKs now have independent version numbers. Check here : Firebase Android Release Notes

So I have changed all firebase libraries version numbers according to documentation in my project. After that Android Studio start showing Warning message on implementation 'com.google.android.gms:play-services-auth:15.0.1'

But it compiles and generating build successfully no error occurring and app running perfectly. After some day I have noticed some issue in Firebase crash logs about google-play-service in my production app. I don't know this happing due to changes or something else. So firstly I want to remove this error message in gradle file. Check: enter image description here

enter image description here

Google Service plugin: classpath 'com.google.gms:google-services:3.2.1' I have three modules here is gradle file of all module and project.

Project gradle:

    buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven {
            url 'https://maven.fabric.io/public'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:3.2.1'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
        classpath 'io.fabric.tools:gradle:1.25.4'

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

allprojects {
    repositories {
         jcenter()
        maven { url "https://jitpack.io" }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app gradle:

    apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "com.xyz.xyz"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 97
        versionName "2.3.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        resConfigs "en", "hi"
    }
    dexOptions {
        javaMaxHeapSize "4072M"
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
        }
        release {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    aaptOptions {
        cruncherEnabled = false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

greendao {
    schemaVersion 62
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation('com.facebook.android:facebook-android-sdk:[4,5)') {
        exclude group: "com.android.support"
    }
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true
    }
    implementation project(path: ':library')
    implementation project(path: ':showcase')
    implementation project(path: ':cropper')
    /* compile 'org.projectlombok:lombok:1.16.16'*/
    /*annotationProcessor 'org.projectlombok:lombok:1.16.16'*/
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:support-v13:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.volley:volley:1.0.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'de.hdodenhof:circleimageview:1.3.0'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'com.github.jd-alexander:LikeButton:0.2.1'
    implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.google.android.gms:play-services-gcm:15.0.1'
    implementation 'com.google.firebase:firebase-auth:15.1.0'
    implementation 'com.google.firebase:firebase-core:15.0.2'
    implementation 'com.google.firebase:firebase-config:15.0.2'
    implementation 'com.google.firebase:firebase-crash:15.0.2'
    implementation 'com.google.firebase:firebase-invites:15.0.1'
    implementation 'com.google.firebase:firebase-messaging:15.0.2'
    implementation 'com.hbb20:ccp:1.8'
    implementation 'com.googlecode.libphonenumber:libphonenumber:8.4.2'
    implementation 'org.greenrobot:greendao:3.2.2'
    implementation 'com.clevertap.android:clevertap-android-sdk:3.1.4'
    testImplementation 'junit:junit:4.12'
    implementation 'android.arch.lifecycle:runtime:1.1.1'
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
    implementation 'org.jetbrains:annotations:15.0'
    implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'it.sephiroth.android.library.targettooltip:target-tooltip-library:1.3.15'
    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    implementation 'com.caverock:androidsvg:1.2.1'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true
    }
}

apply plugin: 'com.google.gms.google-services'

Cropper gradle

 apply plugin: 'com.android.library'

android {

    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 27
        versionCode 1
        versionName '2.4.7'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation "com.android.support:exifinterface:27.1.1"
}

Library gradle:

    apply plugin: 'com.android.library'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    testImplementation 'junit:junit:4.12'
}

SHowcase gradle:

    buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

dependencies {
    repositories {
        mavenCentral()
    }
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
}

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0.0"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
Zoe
  • 27,060
  • 21
  • 118
  • 148
Satwinder Singh
  • 627
  • 1
  • 6
  • 23
  • This type of errors generally emerge when other libraries transitively depending on play-services library also include it. They are showing warning on auth library, as in the list of dependencies, it is the first play-services library. In order to let me try solve this issue, please post your complete build.gradle files of app level and project level. – Kruti Parekh May 15 '18 at 04:33
  • @parekhkruti26 I have added gradle files of project and modules. Please check. – Satwinder Singh May 15 '18 at 04:47
  • Hello @Sunny Dhiman, I am not able to replicate the warning shown to you. I added all build gradles in new project, but this warning does not show up. Try invalidate cache and restart and then update. – Kruti Parekh May 15 '18 at 05:47
  • @parekhkruti26 I have tried all. Everyone suggesting to downgrade libs as its a Know bug using google service. – Satwinder Singh May 15 '18 at 05:59
  • Downgrading libs is the only option, but it will influx downgrading all firebase and play-services libraries. – Kruti Parekh May 15 '18 at 06:04
  • @parekhkruti26 But it doesn't show any compile time error even build successfully works. Should I keep these changes because it only shows a warning message.no functionality breaks? – Satwinder Singh May 15 '18 at 07:25
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/171054/discussion-between-parekhkruti26-and-sunny-dhiman). – Kruti Parekh May 15 '18 at 08:21

4 Answers4

1

The solution is:

Change your dependency to 12.0.1 and downgrade the gradle plugin to version 3.2.1.

There's a known issue about using google-services 3.3 in multimodule apps. That means downgrading to google-services to 3.2.1 may be your only option until a new version that fixes the bug is released.

Koustuv Ganguly
  • 897
  • 7
  • 21
0

The change was introduced Google Services 3.3. So upgrade your classpath to:

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

Since you're using an older version of Google Services, it still validates the older logic that all versions must be the same.

Also see Doug's blog post on this change: https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Also you can change to 3.3.1 – Koustuv Ganguly May 15 '18 at 04:21
  • Getting gradle sync error: `Error:More than one variant of project :library matches the consumer attributes: Configuration ':library:debugApiElements' variant android-aidl:Found artifactType 'android-aidl' but wasn't required........` Someone suggests to downgrade to 3.2.1 : [https://stackoverflow.com/questions/50132601/gradle-more-than-one-variant-of-project-mylib-matches-the-consumer-attributes] – Satwinder Singh May 15 '18 at 04:29
  • @KoustuvGanguly Getting gradle sync error also with 3.3.1 – Satwinder Singh May 15 '18 at 05:30
  • try to change this to 3.2.1 – Koustuv Ganguly May 15 '18 at 05:46
0

What version of Android Studio are you using? That lint error was from before Google Play services and Firebase libraries could be of different versions. https://developer.android.com/studio/releases/, the latest stable (3.1+) version of Android Studio should exempt all newer Google Play services and Firebase libraries from this check (still checks for versions below 15.0.0)

Blog post has more details: https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html

This should be unrelated to the version of the google-services plugin used.

zfromg
  • 170
  • 9
  • My current android studio version is 3.0.1. But it does't show any update in Stable Channel. On Dev and Canery version it show 3.2. – Satwinder Singh May 16 '18 at 06:54
  • OK, I think if you update to Android Studio 3.1 and above, this lint warning will do the right thing. – zfromg May 16 '18 at 19:09
0
syn new all library firebase
implementation 'com.google.firebase:firebase-analytics:17.0.0'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-database:17.0.0'
implementation 'com.google.firebase:firebase-storage:17.0.0'
  • While this code may resolve the OP's issue, it is best to include an explanation as to how your code addresses the OP's issue. In this way, future visitors can learn from your post, and apply it to their own code. SO is not a coding service, but a resource for knowledge. Also, high quality, complete answers are more likely to be upvoted. These features, along with the requirement that all posts are self-contained, are some of the strengths of SO as a platform, that differentiates it from forums. You can edit to add additional info &/or to supplement your explanations with source documentation. – ysf Jun 12 '20 at 19:57
  • that right, but OOP is simple, and resource android have many more and this answer is syn in Studio –  Jun 13 '20 at 06:16