You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

添加Google Maps依赖时触发Firebase版本兼容错误的问题咨询

问题解决:Firebase与Google Play Services版本冲突

你遇到的这个错误是典型的Google服务库版本不兼容问题,我来给你拆解原因和解决办法:

首先看你的依赖配置:

dependencies { 
    implementation fileTree(dir: 'libs', include: ['*.jar']) 
    implementation 'com.android.support:appcompat-v7:26.1.0' 
    implementation 'com.android.support.constraint:constraint-layout:1.1.0' 
    testImplementation 'junit:junit:4.12' 
    implementation 'com.android.support:design:26.1.0' 
    implementation 'com.koushikdutta.ion:ion:2.2.1' 
    implementation 'com.firebase:firebase-client-android:2.5.2' 
    implementation 'com.google.firebase:firebase-core:11.6.2' 
    implementation 'com.google.firebase:firebase-messaging:11.6.2' 
    implementation 'com.google.android.gms:play-services-maps:15.0.1' 
} 
apply plugin: 'com.google.gms.google-services'

错误原因

Google对Firebase和Play Services库有严格的版本一致性要求:所有相关库要么都低于14.0.0,要么都高于14.0.0,不能混合跨这个版本阈值。
你的Firebase核心(firebase-core:11.6.2)和消息推送(firebase-messaging:11.6.2)都是11.x版本,属于低于14.0.0的区间,但新添加的地图库是play-services-maps:15.0.1,属于高于14.0.0的区间,两者版本跨度太大,就触发了这个冲突提示。

解决办法

你有两种可行的修复方向:

  • 方向一:统一升级到高版本
    把所有Firebase库升级到和地图库匹配的15.x版本(注意版本要对应,比如15.0.1的地图对应Firebase的15.0.2版本是兼容的),修改后的依赖大概是:

    implementation 'com.google.firebase:firebase-core:15.0.2'
    implementation 'com.google.firebase:firebase-messaging:15.0.2'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    

    另外建议把老旧的com.firebase:firebase-client-android:2.5.2替换成新的Firebase SDK对应模块,避免潜在的其他兼容性问题。

  • 方向二:统一降级到低版本
    把地图库降级到和Firebase同版本的11.6.2,这样所有库版本保持一致:

    implementation 'com.google.android.gms:play-services-maps:11.6.2'
    

不管选哪种方向,只要保证Firebase和Play Services的所有相关库版本处于同一个大版本区间,这个错误就会消失。

内容的提问来源于stack exchange,提问作者Mehdi bahmanpour

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:46:31