可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am following this link to integrate Google sign-in in my android app.https://developers.google.com/identity/sign-in/android/start-integrating
As given in last step on the above given page we have to include dependency
compile 'com.google.android.gms:play-services-auth:8.3.0'
in app-level build.gradle file but doing so and building project an error comes saying
Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict.
build.gradle(Module:app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.brainbreaker.socialbuttons"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.google.android.gms:play-services-auth:8.3.0'
}
In the build.gradle file the compile dependency line compile 'com.google.android.gms:play-services-auth:8.3.0'
shows error
All com.google.android.gms libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 8.3.0, 8.1.0. Examples include
com.google.android.gms:play-services-base:8.3.0 and
com.google.android.gms:play-services-measurement:8.1.0 There are some
combinations of libraries, or tools and libraries, that are
incompatible, or can lead to bugs. One such incompatibility is
compiling with a version of the Android support libraries that is not
the latest version (or in particular, a version lower than your
targetSdkVersion.)
Here are the messages of gradle build.
Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :social_buttons:generateDebugSources, :social_buttons:generateDebugAndroidTestSources, :social_buttons:compileDebugSources, :social_buttons:compileDebugAndroidTestSources]
:clean UP-TO-DATE
:app:clean
:social_buttons:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library
:app:prepareComAndroidSupportDesign2301Library
:app:prepareComAndroidSupportSupportV42301Library
:app:prepareComGoogleAndroidGmsPlayServicesAds810Library
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics810Library
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing810Library
:app:prepareComGoogleAndroidGmsPlayServicesAuth830Library
:app:prepareComGoogleAndroidGmsPlayServicesBase830Library
:app:prepareComGoogleAndroidGmsPlayServicesBasement830Library
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement810Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
:app:processDebugGoogleServices FAILED
Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict.
Information:BUILD FAILED
Information:Total time: 3.49 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
I am not able to see any way out for this version conflict. Any help is appreciated.
回答1:
I'v got a same issue. but Now I'm fixed.
You should delete a line apply plugin: 'com.google.gms.google-services'
because "com.android.application" package already has same package.
回答2:
I had the same issue and resolved it by adding the following line in the dependencies of the project-level build.gradle:
classpath 'com.google.gms:google-services:3.0.0'
For a full working example, check out the following project on github.
Hope this helps :)
回答3:
I was finding the same error complaining about mixing google play services version when switching from 8.3 to 8.4. Bizarrely I saw reference to the app-measurement lib which I wasn't using.
I thought maybe one of my app's dependencies was referencing the older version so I ran ./gradlew app:dependencies
to find the offending library (non were).
But at the top of task output I found a error message saying that the google plugin could not be found and defaulting to google play services 8.3. I used the sample project @TheYann linked to compare. My setup was identical except I applied the apply plugin: 'com.google.gms.google-services'
at the top my app's build.gradle file. I moved to bottom of the file and that fixed the gradle compile error.
回答4:
I've solved this problem by deleting the google-services.json file and downloading it again from Firebase console.
回答5:
Had the same problem
i added compile 'com.google.android.gms:play-services-measurement:8.4.0'
and deleted apply plugin: 'com.google.gms.google-services'
I was using classpath 'com.google.gms:google-services:2.0.0-alpha6'
in the build project.
回答6:
In my case when i was using firebase services the google.json file was mismatched check once that also
回答7:
had the same issue as described by @scottyab.
all references were 8.4.0 but it failed due to a reference to app-measurement 8.3.0 that i did not reference anywhere (but one of the dependencies?).
you can see the problem if you hover over the bad(red) dependency in Android Studio.
explicitly adding
compile 'com.google.android.gms:play-services-measurement:8.4.0'
to app.gradle
solved the issue.
回答8:
I also faced the same issue. But I forgot to add google-services.json in my project. You can get this file from Google.
回答9:
Important note: You should only apply plugin at bottom of build.gradle (App level)
apply plugin: 'com.google.gms.google-services'
I mistakenly apply this plugin at top of the build.gradle. So I get error.
One more tips : You no need to remove even you use the 3.1.0 or above. Because google not officially announced
classpath 'com.google.gms:google-services:3.1.0'
回答10:
Ensure that you have done these two things under defaultConfig
in Android/app/build.gradle
after wiring up Firebase for your Flutter app.
1) Whatever package name you entered while creating your Firebase android project, exactly the same should be updated as your applicationId
under defaultConfig
.
2) Add the line multiDexEnabled true
under defaultConfig
.
So defaultConfig{}
should now look something like this
defaultConfig {
applicationId "com.companyName.appName"
minSdkVersion 16
targetSdkVersion 27
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
回答11:
First close your android studio
then right click on studio icon and click 'Run as administrator'
it will work
回答12:
I had a similar issue/error..
fixed it by moving
apply plugin: 'com.google.gms.google-services'
to the end of app level gradle file.
And updated the version of gms:play-services
and gms:play-services auth
回答13:
same issue i have.
i tired all possible solutions that i found.
but non were worked.
always got this error
Cannot add task ':processDebugGoogleServices' as a task with that name already exists
Now, i solved it.
1) first i checked my config.xml
2) and removed unnecessary plugin. (I used firebase fcm plugin for pushnotification, but there was two unnecessary plugin phonegap-plugin-push and cordova-plugin-customurlscheme. I removed both these plugins)
3) then removed platform.
4) then add platform
5) then build it.
6) now it build successfully.
回答14:
Had the same problem with malformed error
Deleted the line apply plugin: 'com.google.gms.google-services'
And the build got successful
回答15:
NEVER DELETE apply plugin: 'com.google.gms.google-services' from the gradle. Sometimes you are using com.google.gms:google-services:3.1.0 , without apply plugin: 'com.google.gms.google-services' your gradle build successfully. BUT IT IS COMPLETELY WRONG !!!! This error comes due to google-service.json file is not at the correct location. Go to your PROJECT TAB at left side above. If you display it as ANDROID make it PROJECT then check your google-service.json file is at this location. EXPAND app then see google-service.json file below the build.gradle. IF NOT PLACE IT THERE BY RIGHT CLICK ON THE app .
回答16:
This error comes up when there is change in your config.xml file resulting in mismatching of the data present in google-services.json file.
I got it fixed this just by updating changes to my google-services.json file and building the app again ...it worked well.
回答17:
If you´re building a new app, put the jsonfile in the right place and make sure it's the jsonfile for that app. Before I realized this, when I clicked the jsonfile, I didn't get the information that wanted.
Go to firebase configurations, download the correct version of google-services.json
, and replace the version that didn't work for you. When using the wrong version, you might see the wrong Projectid, storagebucket etc.