问题
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).
回答1:
Make sure you have google()
repository in project-level build.gradle before any others:
allprojects {
repositories {
google()
mavenLocal()
jcenter()
}
}
回答2:
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
回答3:
I encountered the same issue after updating. Try to verify if you installed the latest Build Tool and Google Repository versions.
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
}
回答4:
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!
回答5:
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'
}
}
回答6:
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
回答7:
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.
回答8:
Possible reasons would be
- Internet not connected/work Offline not enabled from AndroidStudio Preference
- Cached versions of dependancy not exists
- Proxy enabled
- 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
回答9:
Build -> Clean Project
was enough in my special case (with gms:v15.0.1
and firebase:v16.0.1
).
回答10:
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
回答11:
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'
回答12:
build.gradle(app)
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
来源:https://stackoverflow.com/questions/50791632/could-not-find-any-version-that-matches-com-google-android-gmsplay-services-bas