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

Flutter集成in_app_review插件遇Play Core依赖冲突求助

Flutter集成in_app_review插件重复依赖问题解决方案

问题原因

项目同时引入了旧版com.google.android.play:core(1.8.0)和新版拆分后的Play Core组件(如core-common:2.0.2、review:2.0.1),导致类定义重复冲突。in_app_review插件本身依赖新版Play Review组件,而其他第三方插件可能仍在依赖旧版完整Play Core库。

解决方案

1. 定位冲突依赖

执行命令排查依赖树,找到引入旧版Play Core的插件:

# 查看Flutter依赖树
flutter pub deps --style=compact

# 或查看Android Gradle依赖详情
cd android
./gradlew app:dependencies

查找包含com.google.android.play:core:1.8.0的依赖路径,定位到对应的Flutter插件。

2. 排除重复依赖

方式一:在pubspec.yaml中针对冲突插件排除依赖

找到冲突插件后,添加依赖排除规则:

dependencies:
  # 替换为你找到的冲突插件名称及版本
  problematic_plugin: ^x.x.x
  in_app_review: ^x.x.x

dependency_overrides:
  problematic_plugin:
    dependencies:
      # 排除该插件引入的旧版Play Core
      android_intent_plus:
        exclude:
          group: com.google.android.play
          module: core

方式二:全局排除旧版Play Core

在Android模块的app/build.gradle中添加全局排除规则:

android {
    // ...其他配置
    configurations.all {
        exclude group: 'com.google.android.play', module: 'core'
    }
}

3. 统一Play Core版本

在android/build.gradle的ext块中指定统一版本,强制所有依赖使用新版组件:

buildscript {
    ext {
        playCoreCommonVersion = "2.0.2"
        playReviewVersion = "2.0.1"
    }
    // ...其他配置
}

然后在app/build.gradle中声明依赖:

dependencies {
    // ...其他依赖
    implementation "com.google.android.play:core-common:$playCoreCommonVersion"
    implementation "com.google.android.play:review:$playReviewVersion"
}

4. 清理缓存并重建

执行命令清理缓存,避免残留旧依赖影响构建:

flutter clean
flutter pub get
cd android && ./gradlew clean
cd ..
flutter run

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.31 11:31:35