Search code examples
androidfirebasegoogle-mapsgoogle-maps-api-3firebase-mlkit

Failed to resolve: com.google.android.gms:play-services:15.0.1 after adding ML Kit


Look here Please I tried to add ML Kit to my app's build gradle but it didn't run completely. I guess it must be from my build.gradle file but I don't know where. Please help?

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

    //Firebase libraries
    implementation 'com.google.firebase:firebase-auth:16.0.2'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'
    implementation 'com.google.firebase:firebase-ads:15.0.1'
    implementation 'com.google.firebase:firebase-ml-vision:16.0.0'

    //Other Stuff
    implementation 'com.firebase:geofire-android:2.3.0'
    implementation 'com.android.support:support-vector-drawable:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:support-v13:27.1.1'
    implementation 'com.r0adkll:slidableactivity:2.0.6'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.android.support:multidex:1.0.3'
    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'
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation 'com.google.android.gms:play-services:15.0.1'
}

Below is the build.gradle(project). I have even included the google repository but still to no avail. Please help

    buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0-alpha03'

        classpath 'com.google.gms:google-services:4.0.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven{
            url 'https://maven.google.com'
        }
    }
}

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

Solution

  • The Google API Release Notes indicate that support for the combined play-services library ended in April 2018:

    Starting with 15.0.0, there will no longer be a play-services alias target to pull in all Google Play services components. This has been recommended against for some time.

    You can no longer specify a dependency on the combined Google Play services target, implementation 'com.google.android.gms:play-services:15.0.1'. When this was supported with previous versions, it pulled in ALL the Google Play libs--way more than you need. See the list of APIs in Table 1 of the Setup Guide and include only the specific ones your app uses.

    A check of the Google Maven Repository confirms that version 12.0.1 was the last version of the combined play-services` target.