4

When syncing the project this error is appearing:

The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 16.0.1.

Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

This is my build.gradle Project file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
    google()
    jcenter()
    maven {
        url 'https://maven.fabric.io/public'
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath 'com.google.gms:google-services:4.1.0'
    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 {
    google()
    jcenter()
    maven {
        url 'https://maven.google.com/'
    }
}
}

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

And this is my build.gradle app file:

import com.google.gms.googleservices.GoogleServicesPlugin

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
compileSdkVersion 27
defaultConfig {
    multiDexEnabled true
    applicationId "com.example.myexampleapp"
    minSdkVersion 19
    targetSdkVersion 27
    versionCode 13
    versionName "0.1.13"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-firestore:17.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.firebaseui:firebase-ui-firestore:4.1.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'

What I have tried:

Thank you for your help!

Update: This is what I currently have in my dependencies:

dependencies {
api "com.android.support:appcompat-v7:28.0.0"
api "com.android.support:customtabs:28.0.0"
api "com.android.support:support-v4:28.0.0"
api "com.android.support:cardview-v7:28.0.0"
api "com.android.support:design:28.0.0"
api "com.android.support.constraint:constraint-layout:1.1.3"

api "com.crashlytics.sdk.android:crashlytics:2.9.5"
api "com.google.android.gms:play-services-base:16.0.1"
api "com.google.android.gms:play-services-auth:16.0.1"

api "com.google.firebase:firebase-core:16.0.5"
api "com.google.firebase:firebase-auth:16.0.5"
api ("com.google.firebase:firebase-firestore:17.1.2") {
    exclude group: "com.squareup.okhttp", module: "okhttp"
}
api ("com.firebaseui:firebase-ui-firestore:4.1.0") {
    exclude group: "com.google.code.gson", module: "gson"
}
api ("com.firebaseui:firebase-ui-auth:4.1.0") {
    exclude group: "com.google.code.gson", module: "gson"
}
implementation fileTree(dir: 'libs', include: ['*.jar'])
}

And this is the error that I am getting:

error: cannot find symbol class IFlagProvider

jonasxd360
  • 1,225
  • 4
  • 19
  • 35
  • Have you checked this [related SO post](https://stackoverflow.com/questions/50577437/com-google-android-gmsplay-services-measurement-base-is-being-requested-by-vari)? – Jessica Rodriguez Oct 19 '18 at 09:00
  • Yes, the answers on it didn't work for me; I either got the same error, or later on when building the app I got some errors that point back to the same error. Thanks – jonasxd360 Oct 19 '18 at 12:00
  • as a test remove `implementation 'com.google.android.gms:play-services-auth:16.0.1'` and see if it works, and tell me what do you get – Peter Haddad Nov 04 '18 at 17:09
  • @PeterHaddad yes, the error message did not change, but thanks for your suggestion – jonasxd360 Nov 04 '18 at 17:37

1 Answers1

3

these dependencies make it build:

dependencies {
    implementation "com.android.support:appcompat-v7:28.0.0"
    implementation "com.android.support:customtabs:28.0.0"
    implementation "com.android.support:support-v4:28.0.0"
    implementation "com.android.support:cardview-v7:28.0.0"
    implementation "com.android.support:design:28.0.0"
    implementation "com.android.support.constraint:constraint-layout:1.1.3"

    implementation "com.google.android.gms:play-services-base:16.0.1"
    implementation "com.google.android.gms:play-services-auth:16.0.1"

    implementation "com.crashlytics.sdk.android:crashlytics:2.9.5"

    implementation "com.google.firebase:firebase-core:16.0.4"
    implementation "com.google.firebase:firebase-auth:16.0.4"

    implementation ("com.google.firebase:firebase-firestore:18.0.0") {
        exclude group: "com.squareup.okhttp", module: "okhttp"
        exclude group: "com.google.code.gson", module: "gson"
        // exclude group: "com.google.guava", module: "guava"
    }

    implementation ("com.firebaseui:firebase-ui-firestore:4.1.0") {
        exclude group: "com.google.code.gson", module: "gson"
    }

    implementation ("com.firebaseui:firebase-ui-auth:4.1.0") {
        exclude group: "com.google.code.gson", module: "gson"
    }
}

I've added customtabs:28.0.0 to meet the required version and play-services-base:16.0.0 (which should be fetched as transitive dependency). also excluded duplicate packages, eg. gson. used compileSdkVersion and targetSdkVersion 28.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • Should I change all of the `implementation`s to api? – jonasxd360 Nov 04 '18 at 15:45
  • It worked, but when building the app I am getting this `error: package com.google.gson does not exist` – jonasxd360 Nov 04 '18 at 15:54
  • I am also getting this error now: `error: cannot find symbol class TypeToken` – jonasxd360 Nov 04 '18 at 15:56
  • I removed the exclude for gson, but I am still getting this error: `error: cannot find symbol class IFlagProvider` Thanks – jonasxd360 Nov 04 '18 at 16:13
  • @jonasxd360 commented out two excludes. `TypeToken` should be provided by `guava`. in general, each of them must only be added once, else there are duplicates, which cannot be added into the package. – Martin Zeitler Nov 04 '18 at 16:56
  • `com.google.android.gms:play-services-basement` might even come from some library in the `libs` directory - because this name hints for an outdated version. – Martin Zeitler Nov 04 '18 at 16:59
  • After updating the code I am still getting this error: `error: cannot find symbol class IFlagProvider` Thanks for your help! – jonasxd360 Nov 04 '18 at 17:05
  • @jonasxd360 that might be `com.google.android.gms.flags.IFlagProvider`. do you have any libraries in the `libs` directory and if yes, which? it might not be possible to build against two different versions of play-services, with `play-services-basement` (until `12.0.0`) and `play-services-base` ( > `15.0.0`). one could in best case build library jars from source and update their dependencies accordingly. – Martin Zeitler Nov 04 '18 at 17:18
  • My libs directory is empty – jonasxd360 Nov 04 '18 at 17:21
  • remove that `import com.google.gms.googleservices.GoogleServicesPlugin`. it may only add to the problem (those build-script dependencies are all Gradle plugins, not Java dependencies). – Martin Zeitler Nov 04 '18 at 17:28
  • Thanks for your help! (I ended up removing import IFlagProvider from one of my classes, then your solution worked) – jonasxd360 Nov 09 '18 at 14:24
  • build.gradle is show only platform/android/buid.grdle but sir project level gradle is not show in my location sir? – Kapil Soni May 08 '19 at 10:41