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

升级Google Play服务与Firebase至15.0.0后出现ImmutableJarInput错误

解决Google Play服务(及Firebase)升级至15.0.0后的IllegalStateException错误

这个问题我之前帮不少开发者排查过,本质就是依赖版本不统一闹的——你升级到15.0.0版本后,还有部分Google Play服务的子库(比如报错里的play-services-location-license:12.0.1、play-services-auth-api-phone-license:12.0.1)还停留在旧版本,Gradle在处理这些版本不一致的依赖时,desugar转换步骤就抛出了异常。

下面是具体的解决步骤:

  • 强制统一所有Google Play服务和Firebase库的版本
    最稳妥的方式是在项目根目录的build.gradle里统一定义版本号,避免手动写版本时出现遗漏:

    buildscript {
        ext {
            // 统一设置Google Play服务和Firebase的版本
            google_services_version = '15.0.0'
            firebase_version = '15.0.0'
        }
        repositories {
            google()
            jcenter()
        }
        // 其他buildscript配置...
    }
    

    然后在模块(通常是app)的build.gradle里,所有相关依赖都引用这个统一版本:

    implementation "com.google.android.gms:play-services-location:$google_services_version"
    implementation "com.google.android.gms:play-services-auth-api-phone:$google_services_version"
    implementation "com.google.firebase:firebase-core:$firebase_version"
    // 其他Google/Firebase相关依赖...
    
  • 排查并排除旧版本依赖
    有些第三方库可能会偷偷引入旧版本的Google服务库,你可以用Gradle命令查看完整依赖树:

    ./gradlew app:dependencies
    

    找到引入12.0.1版本库的那个第三方依赖,然后在implementation里添加排除规则:

    implementation('你的第三方依赖库') {
        exclude group: 'com.google.android.gms', module: 'play-services-location-license'
        exclude group: 'com.google.android.gms', module: 'play-services-auth-api-phone-license'
    }
    
  • 更新Google Services插件版本
    插件版本要和库版本匹配,15.0.0的库对应3.3.0版本的插件,在根目录build.gradle里修改:

    buildscript {
        dependencies {
            classpath 'com.google.gms:google-services:3.3.0'
        }
    }
    
  • 清理重建项目
    最后执行清理和重建,确保所有旧依赖被移除:

    ./gradlew clean
    ./gradlew assembleDebug
    

核心原因就是Google Play服务和Firebase的所有子库必须保持版本一致,否则内部API、依赖结构不兼容,会导致Gradle的字节码转换(desugar)过程出错,抛出IllegalStateException。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 07:57:23