如何修复 google 播放服务错误

How to fix google play service error

今天更新根文件夹中的播放服务后,我遇到了以下问题。我很困惑如何解决这个问题。

谁能帮我解决这个问题?

这个错误很烦人。不知道哪里冲突了。顺便说一下为什么它显示冲突而没有版本相互关联。

错误

The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]], but resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

build.gradle 脚本:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'



android {
configurations.all {
    resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
    applicationId "community.infinity"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
aaptOptions {
    cruncherEnabled = false
}
dexOptions {
    preDexLibraries false
    javaMaxHeapSize "4g"
}
buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-rules.pro'
    }
    debug {
        ext.enableCrashlytics = false
    }
}

compileOptions {
    targetCompatibility 1.8
    sourceCompatibility 1.8
}

}

 dependencies {

implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support'
    exclude module: 'support-annotations'
    exclude module: 'support-v4'
    exclude module: 'support-v13'
    exclude module: 'recyclerview-v7'
    exclude group: 'com.android.support', module: 'appcompat-v7'
})
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
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:support-v4:27.1.1'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.adamstyrc.cookiecutter:cookie-cutter:1.0.2'
implementation 'com.allattentionhere:fabulousfilter:0.0.5'
implementation 'com.github.florent37:diagonallayout:1.0.6'
implementation 'com.flaviofaria:kenburnsview:1.0.7'
implementation 'com.vstechlab.easyfonts:easyfonts:1.0.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.github.pwittchen:swipe:0.1.0'
implementation 'com.thesurix.gesturerecycler:gesture-recycler:1.4.0'
implementation 'com.github.iammert:MaterialIntroView:1.6.0'
implementation 'com.github.oxoooo:touch-image-view:1.0.1'
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
implementation 'com.squareup.okhttp:okhttp-urlconnection:1.6.0'
implementation('io.socket:socket.io-client:0.8.3') {
    // excluding org.json which is provided by Android
    exclude group: 'org.json', module: 'json'
}
implementation 'com.google.gms:google-services:3.3.0'
implementation 'com.iceteck.silicompressorr:silicompressor:2.1'
implementation 'com.fenchtose.nocropper:nocropper:0.2.0'
implementation 'me.relex:circleindicator:1.2.2@aar'
implementation('com.google.guava:guava:23.4-android') {
    exclude group: 'com.android.support'
    exclude module: 'support-annotations'
    exclude module: 'support-v4'
    exclude module: 'support-v13'
    exclude module: 'recyclerview-v7'
    exclude group: 'com.android.support', module: 'appcompat-v7'
}
implementation 'com.github.amlcurran.showcaseview:library:5.4.3'
implementation 'com.orhanobut:hawk:2.0.1'
implementation 'com.zsoltsafrany:needle:1.0.0'
implementation 'com.github.madrapps:pikolo:1.1.6'
implementation 'jp.wasabeef:richeditor-android:1.2.2'
implementation 'com.android.support:palette-v7:27.1.1'
testImplementation 'junit:junit:4.12'
implementation('com.github.bumptech.glide:glide:4.4.0') {
    transitive = true
}
implementation ("com.github.bumptech.glide:recyclerview-integration:4.4.0")   {
    // Excludes the support library because it's already included by Glide.
    transitive = false
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
implementation 'com.android.support:multidex:1.0.3'
implementation "me.leolin:ShortcutBadger:1.1.21@aar"
implementation 'com.hbb20:ccp:2.1.2'

}

您的一个依赖项是 com.google.android.gms 的不同版本。

更新

Firebase dependencies are having independent versions unlike past. If you have version conflicts then you can update your com.google.gms:google-services. and start defining independent version.

更新com.google.gms:google-services

Go to top (project) level build.gradle and update com.google.gms:google-services to version 4.1.0 or newer if available.

buildscript {
    ...
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath 'com.google.gms:google-services:4.1.0' //< update this 
    }
}

将 Firebase 依赖项更新为 Latest Versions

Firebase 依赖项版本可以是单独的。所以检查 Latest Versions.

com.google.firebase:firebase-core:16.0.3    //Analytics
com.google.firebase:firebase-database:16.0.2    //Realtime Database

原始解决方案(有用)

解决方法:

  1. com.google.android.gms 来自冲突的依赖。
  2. 更新那个依赖if available.
  3. 将您的 com.google.android.gms 版本更改为冲突版本。

问题

如何查看哪个依赖项正在使用 com.google.android.gms

1。命令解决

对于Android,使用这一行

 gradle app:dependencies

或者如果您有 gradle 包装器:

./gradlew app:dependencies

其中 app 是您的项目模块。

另外,如果你想检查某些东西是否是 compile vs. testCompile vs androidTestCompile 依赖以及是什么在拉它:

./gradlew :app:dependencyInsight --configuration compile --dependency <name>
./gradlew :app:dependencyInsight --configuration testCompile --dependency <name>
./gradlew :app:dependencyInsight --configuration androidTestCompile --dependency <name>

2 使用这些插件

Gradle View 是一个 Android Studio 插件,您可以安装它并显示依赖关系层次结构。 Methods Count 是另一个插件,它也显示依赖树。

Firebase 组件现在可以有独立版本(参见最新发行说明:https://firebase.google.com/support/release-notes/android

可能发生的情况是您的其他依赖项之一正在引入多个版本的 com.google.firebase:* 依赖项超出您对

的显式依赖项
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'

您可以通过将 firebase-messaging 的依赖项移动到 15.0.2 来解决这个特定问题。

Firebase Android SDK now have independent version numbers,允许更频繁、更灵活的更新。

更新google play gradle插件版本到最新版本,目前是3.3.0。

classpath 'com.google.gms:google-services:3.3.0'

并将库更新到 latest version

Firebase Core   com.google.firebase:firebase-core:15.0.2
Ads             com.google.firebase:firebase-ads:15.0.0
Analytics       com.google.firebase:firebase-analytics:15.0.2
App Indexing    com.google.firebase:firebase-appindexing:15.0.0
Authentication  com.google.firebase:firebase-auth:15.1.0
Cloud Firestore com.google.firebase:firebase-firestore:16.0.0
Cloud Functions com.google.firebase:firebase-functions:15.0.0
Cloud Messaging com.google.firebase:firebase-messaging:15.0.2
Cloud Storage   com.google.firebase:firebase-storage:15.0.2
Crash Reporting com.google.firebase:firebase-crash:15.0.2
Crashlytics     com.crashlytics.sdk.android:crashlytics:2.9.1
Invites         com.google.firebase:firebase-invites:15.0.2
Performance Monitoring  com.google.firebase:firebase-perf:15.1.0
Realtime Database   com.google.firebase:firebase-database:15.0.0
Remote Config   com.google.firebase:firebase-config:15.0.2

同样 reported 至少使用版本 15.0.2:

You will need to update the version of the latter dependency to 15.0.2. This addresses the issue where version 3.3.0 of the Google Services Gradle plugin reports: The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]], but resolves to 15.0.2...

我 运行 解决了这个问题,并在本节中找到了我的解决方案 https://firebase.google.com/support/release-notes/android#20180508

这表明并非所有 firebase 依赖项都具有与当前构建相同的版本号。所以你需要独立更新每一个。我的最终配置如下所示:

implementation "com.google.firebase:firebase-core:15.0.2" implementation "com.google.firebase:firebase-ml-vision:15.0.0" implementation "com.google.firebase:firebase-appindexing:15.0.0" implementation "com.google.android.gms:play-services-ads:15.0.0" implementation "com.google.android.gms:play-services-maps:15.0.0" implementation "com.google.android.gms:play-services-places:15.0.0" implementation "com.google.android.gms:play-services-location:15.0.0" implementation "com.google.firebase:firebase-auth:15.0.0" implementation "com.google.firebase:firebase-database:15.0.0" implementation "com.firebaseui:firebase-ui-database:1.0.1" implementation "com.google.firebase:firebase-storage:15.0.2" implementation "com.google.firebase:firebase-messaging:15.0.2"

希望您能看到 google 服务插件 3.3.0

带来的差异和新更新

对我来说,我需要将 com.google.android.gms:play-services-base 更新到版本 15.0.1 而不是 15.0.0

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

需要将核心库组件与其他 firebase 组件一起使用:

implementation 'com.google.firebase:firebase-core:16.0.0'

试试这个对我有用。

将此添加到您的 build.gradle 文件末尾

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

使用google播放服务。版本 4.3.0

googleServices.disableVersionCheck = true

我为此浪费了 4 天时间,以下是对我有用的确切步骤:

cordova build android

删除平台文件夹

ionic cordova platform remove android
ionic cordova plugin remove cordova-plugin-firebase
ionic cordova plugin add cordova-plugin-firebase-lib@3.3.0
ionic cordova plugin add cordova-plugin-androidx-adapter
cordova build android
ionic cordova platform add android
cordova plugin add cordova-plugin-whitelist
ionic cordova emulate

通过关注更新解决问题 在 android project.properties

cordova.system.library.3=com.google.firebase:firebase-core:16.0.0
cordova.system.library.10=com.google.firebase:firebase-messaging:17.0.+

并在 android cordova 中支持 google 服务 -build.gradle

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

ext.postBuildExtras = {
  if (project.extensions.findByName('googleServices') == null) {
    // apply plugin: 'com.google.gms.google-services'
    // class must be used instead of id(string) to be able to apply plugin from non-root gradle file
    apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
    googleServices { disableVersionCheck = true }
  }
}

这可能对你也有帮助。