44

I am using firebase for my android app and suddenly I am getting an error when I tried to run the app. Saturday it was working perfectly. I don't know how this error occurred and how to solve this. Please help me.

dependencies in my build.gradle

dependencies {
    compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
        transitive = true;
    }
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:cardview-v7:23.4.0'
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'
    compile 'com.google.code.gson:gson:2.8.4'
    compile 'com.android.support:multidex:1.0.3'
    compile 'com.microsoft.azure:azure-mobile-android:3.1.0'
    compile 'com.mixpanel.android:mixpanel-android:4.8.0'
    compile 'com.firebase:firebase-client-android:2.4.0'

    compile 'com.google.firebase:firebase-core:16.0.0'
    compile 'com.google.firebase:firebase-auth:16.0.1'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.j256.ormlite:ormlite-android:4.48'
    compile 'com.j256.ormlite:ormlite-core:4.48'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.github.tibolte:elasticdownload:1.0.+'
    compile 'me.dm7.barcodescanner:zxing:1.8.4'
    compile 'com.google.android.gms:play-services-vision:15.0.2'
    compile 'com.android.support.constraint:constraint-layout:1.1.1'
    compile 'com.github.amlcurran.showcaseview:library:5.4.3'
    compile 'com.wang.avi:library:2.1.3'
    testCompile 'junit:junit:4.12'
    androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.6.0'
    androidTestCompile 'com.android.support.test:rules:1.0.2'
}
apply plugin: 'com.google.gms.google-services'

In my project level build.gradle:

dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.google.gms:google-services:4.0.0'
    }

The Error I am getting:

Could not find any version that matches com.google.android.gms:play-services-base:[15.0.1,16.0.0).

Riddhi Shah
  • 3,092
  • 5
  • 36
  • 56

16 Answers16

35

Make sure you have google() repository in project-level build.gradle before any others:

allprojects {
    repositories {
        google()
        mavenLocal()
        jcenter()
    }
}
mpontus
  • 2,143
  • 2
  • 19
  • 21
  • 1
    As you suggested, I included `google()` repository. then an error showed and a link to update gradle version I updated that after that, I am getting a new error, `Failed to resolve: com.google.firebase:firebase-auth:16.0.0 ` Can you help me with that? – Riddhi Shah Jun 11 '18 at 07:11
  • 2
    Look for `com.google.firebase:firebase-auth:16.0.0` in app-level build.gradle, and try switching it to `com.google.firebase:firebase-auth:16.0.1`. https://firebase.google.com/docs/auth/android/start/ – mpontus Jun 11 '18 at 07:14
18

Add this line in build.gradle

apply plugin: 'com.google.gms.google-services'
// Work around for onesignal-gradle-plugin compatibility
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

or

googleServices.disableVersionCheck = true
shuabing
  • 679
  • 11
  • 28
Gautam Surani
  • 1,136
  • 10
  • 21
10

I encountered the same issue after updating. Try to verify if you installed the latest Build Tool and Google Repository versions.

enter image description here

Also, verify the Project's build.gradle that you're using google() and the build tool version. After checking the build.gradle, try to re-sync, clean, and re-build your project.

If needed, try to update to the latest version of your project's dependencies.

buildscript {

    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
    }
    // ...
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
jjz
  • 2,007
  • 3
  • 21
  • 30
5

in my case i just update Andorid SDK Platform-Tools previous was 28.0.0 when i updated it to 28.0.1 problem fix!

enter image description here

Erfan
  • 3,059
  • 3
  • 22
  • 49
4
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
}

apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
Andronicus
  • 25,419
  • 17
  • 47
  • 88
M E S A B O
  • 783
  • 1
  • 11
  • 15
4

All of sudden with out any changes in my project I was getting below error.

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0).

In project level build.gradle

buildscript {
    ext.kotlin_version = '1.3.21'
    repositories {
        google()
        jcenter()
        maven {
            url 'https://dl.bintray.com/android/android-tools'
        }
    }
dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
    }

and

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

with above settings I had no luck.

Below is what worked for me I found that the problem is with onesignal

I added exclude clause to dependency:

implementation ('com.onesignal:OneSignal:3.10.5') {
    exclude group: 'com.google.android.gms'
}

then added the missing dependencies manually. After adding exclude clause I got Could not resolve com.google.firebase:firebase-messaging:[10.2.1, 12.1.0). If you find any other missing dependencies just do as I did below.

In the module level build.gradle I replaced

implementation 'com.google.firebase:firebase-messaging:17.4.0' with
implementation 'com.google.firebase:firebase-messaging:10.2.1'

and finally Build completed successfully. I wasted almost 5 hours on this. Hope this helps some one.

WIT_NGU
  • 136
  • 5
3

In my case everything was working fine, but suddenly I encountered this problem in the next "run action"!

Anyway, the problem is solved by updating com.google.gms:google-services in the project build.gradle file to its latest version as the below :

buildscript {

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

    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath 'com.google.gms:google-services:4.3.0'
    }
}

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

}

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

Also, make sure that:
- You are not in offline mode.
- And if you are using Http Proxy, you can connect to the google repository.

Note (in the above sample):
Android Studio : 3.4.2
compileSdkVersion 28
targetSdkVersion 28

Ghasem Sadeghi
  • 1,734
  • 13
  • 24
2

Build -> Clean Project

was enough in my special case (with gms:v15.0.1 and firebase:v16.0.1).

Community
  • 1
  • 1
Mir-Ismaili
  • 13,974
  • 8
  • 82
  • 100
2

I solved this issue with this build.gradle [Proyect]

buildscript {
    ext.kotlin_version = '1.2.30'
    repositories {
        google()
        jcenter()
        maven {
            url 'https://dl.bintray.com/android/android-tools'
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
    }
}
teteArg
  • 3,684
  • 2
  • 20
  • 18
2

OPTION 1:

Follow the below instruction to resolve it.

Project-level build.gradle

use

maven { url "https://www.jitpack.io" }

instead of

maven { url "https://jitpack.io" }

OPTION 2:

Follow the below steps to resolve it.

Step1:

Project-level build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.2.0' // google-services plugin
        classpath 'com.android.tools.build:gradle:3.4.2'

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

allprojects {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        maven { url "https://jitpack.io" } // For Ucrop
        maven { url "https://maven.google.com" } // Google's Maven repository - FCM
        maven {
            url 'https://dl.bintray.com/azeesoft/maven'
        }
        google()
        jcenter()
        mavenCentral()
    }
}

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

Step2:

App-level build.gradle

I have update One Signal version.

use

implementation 'com.onesignal:OneSignal:3.11.1'

instead of

implementation 'com.onesignal:OneSignal:3.10.9' 
VIISHRUT MAVANII
  • 11,410
  • 7
  • 34
  • 49
2

Changing

implementation('com.onesignal:OneSignal:3.15.1')

with

  implementation('com.onesignal:OneSignal:3.15.1') {
    exclude group: 'com.android.support', module: 'customtabs'
    exclude group: 'com.google.android.gms'
}

solved my problem.

Ahmet B.
  • 1,290
  • 10
  • 20
2

This is what worked for me. In project-level Gradle file use the following order:

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

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
        jcenter()
    }
}
Anuj Raghuvanshi
  • 664
  • 1
  • 7
  • 24
Fivos
  • 558
  • 8
  • 19
1

Possible reasons would be

  1. Internet not connected/work Offline not enabled from AndroidStudio Preference
  2. Cached versions of dependancy not exists
  3. Proxy enabled
  4. Google Play Service Temporarily Unavailable

Solution :

Along with the above answers don't forget to add mavenLocal() inside project level build.gradle

allprojects {
    repositories {
                   ......
                   ......

                   mavenLocal()
    }
}

This helps to access cached dependencies when Service Temporarily Unavailable

Suresh Maidaragi
  • 2,173
  • 18
  • 25
0

i deleted every firebase plugin like:

  1. firebase_core
  2. cloud_firestore
  3. firebase_dynamic_links
  4. firebase_messaging
  5. firebase_auth

from pubspec.yaml

and run pub get and flutter run

add packages again

run pub get and flutter run again

worked for me.

if not fixed, try packages one by one

Mohammad Shamsi
  • 521
  • 4
  • 11
0

go to build.gradle in android directory , insert

maven { url 'https://maven.google.com' }

in top position of repositories of allprojects same this :

allprojects {
repositories {
    maven { url 'https://maven.google.com' } //<<--Insert this above google()
    google()
0

i was facing this error failed to resolve com.google.firebase:firebase-ml-vision-image-label-model:20.1.0 solution just remove the

com.google.firebase:firebase-ml-vision-image-label-model:20.1.0

from the gradle.build (app)

Zaman Rajpoot
  • 326
  • 2
  • 5