【问题标题】:How to fix google play service error如何修复谷歌播放服务错误
【发布时间】:2020-06-07 08:10:41
【问题描述】:

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

谁能帮我解决这个问题?

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

错误

库 com.google.android.gms:play-services-measurement-base 是 被 [[15.0.0,15.0.0] 的其他各种图书馆请求, [15.0.2,15.0.2]],但解析为 15.0.2。禁用插件并检查 你的依赖树使用 ./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'

}

【问题讨论】:

标签: android firebase google-play-services build.gradle


【解决方案1】:

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

更新

Firebase 依赖项具有与过去不同的独立版本。如果 你有版本冲突然后你可以更新你的 com.google.gms:google-services。并开始定义独立 版本。

更新com.google.gms:google-services

转到顶层(项目)级 build.gradle 并将 com.google.gms:google-services 更新到版本 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. Exclude 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 是您的项目模块。

此外,如果您想检查某些东西是 compiletestCompileandroidTestCompile 依赖关系,以及是什么在拉动它:

./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 是另一个插件,它也显示依赖树。

【讨论】:

  • Methods Count 已关闭,因此无法再提供新的或更新的库方法计数。
  • Firebase Android SDK 现在有独立的版本号,允许更频繁、更灵活的更新。
  • 最好使用最新版本的firebase依赖来解决这个问题。
  • @Khemraj 当我尝试包含 play-services-analyticsfirebase-core 时,我得到了同样的错误。对于CampaignTrackingReceiver,我需要play-services-analytics,对于AppMeasurementInstallReferrerReceiver,我需要firebase-core。这里有更多细节:stackoverflow.com/questions/51514926/…
  • 你检查过哪个依赖是重复的吗?
【解决方案2】:

试试这对我有用。

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

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

使用谷歌播放服务。版本 4.3.0

googleServices.disableVersionCheck = true

【讨论】:

  • 它对我有用,用它解决了 8 个传递依赖错误
  • Google Play服务插件4.3.0及以上版本,使用googleServices.disableVersionCheck = true
  • @Akshay 我使用上面的代码,但我收到错误:未找到 ID 为 'com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true' 的插件。你能告诉我为什么我来
  • 我使用这种方法,但是当我想编译项目时,它说 RecyclerView 符号未找到,而且这似乎是一种奇怪的方法
  • 为了说明清楚,添加到app级别build.gradle
【解决方案3】:

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 版本:

您需要将后一个依赖项的版本更新为 15.0.2。这解决了 Google Services Gradle 插件版本 3.3.0 报告的问题:库 com.google.android.gms:play-services-measurement-base 正在被 [[15.0.0,15.0. 0], [15.0.2,15.0.2]],但解析为 15.0.2...

【讨论】:

  • use at least the version 15.0.2 是什么意思?!比如有些库的最新版本是15.0.1,比如play-services-location:15.0.1
【解决方案4】:

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

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

【讨论】:

  • @holydragon 在您的应用程序 gradle 文件中,dependencies
  • 对于 18.0.1 版仍然出现此错误
【解决方案5】:

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 来解决此特定问题。

【讨论】:

    【解决方案6】:

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

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

    【讨论】:

      【解决方案7】:

      我为此浪费了 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
      

      【讨论】:

        【解决方案8】:

        我遇到了这个问题,并在本节中找到了我的解决方案 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"

        希望你能看到谷歌服务插件 3.3.0 带来的不同和新的更新

        【讨论】:

          【解决方案9】:

          通过以下更新解决问题 在 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 service -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 }
            }
          }
          

          这对你也有帮助。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2016-06-08
            • 2017-03-21
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2014-06-12
            • 2014-08-18
            相关资源
            最近更新 更多