You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

执行gradlew :app:dependencyInsight命令未找到匹配依赖的问题排查

解决dependencyInsight找不到firebase-messaging依赖的问题

你的问题核心在于Android Gradle Plugin(AGP)3.0及以上版本已经彻底废弃了compile配置,取而代之的是implementationapi等更精细化的依赖配置。你执行命令时指定的:app:compile配置早已不再承载项目的主代码依赖,所以才会返回"No dependencies matching given input were found"。

正确的解决步骤:

  • 使用对应配置执行查询命令
    如果你是在主业务代码中引入的firebase-messaging,直接替换配置名称为implementation即可:

    gradlew :app:dependencyInsight --configuration implementation --dependency firebase-messaging
    

    要是firebase-messaging是debug环境专属依赖,就换成debugImplementation;如果是测试代码依赖,用testImplementation

  • 先确认依赖所在配置(可选)
    如果你不确定firebase-messaging归属于哪个配置,可以先执行命令查看完整依赖树,定位它的位置:

    gradlew :app:dependencies
    

    在输出内容里搜索firebase-messaging,就能看到它所属的配置分组。

  • 检查依赖是否正确引入
    最后确认你的Module级别build.gradle里是否添加了正确的依赖声明,类似这样:

    dependencies {
        // 替换为你实际使用的版本号
        implementation 'com.google.firebase:firebase-messaging:23.0.0'
    }
    

    同时别忘了确保文件末尾应用了Google服务插件(apply plugin: 'com.google.gms.google-services'),且Project级别的build.gradle已配置Google Maven仓库。

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

火山引擎 最新活动