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

运行pub get报错geocoder插件使用已弃用Android embedding如何解决?

Flutter geocoder插件Android embedding废弃报错解决方案

报错原文:The plugin geocoder uses a deprecated version of the Android embedding. To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
报错翻译:geocoder插件使用了已废弃的Android embedding版本。为避免出现意外的运行时故障或后续构建失败,请先确认该插件是否支持Android V2 embedding。如果不支持建议移除该插件,因为未来的Flutter版本会彻底删除这些废弃API。

最优解决方案:替换为维护状态正常的同类插件

  • 官方geocoder插件已经停止维护多年,默认不支持Android V2 embedding,优先选择仍在更新的社区主流替代库geocoding,该库完全适配Android V2 embedding,功能覆盖原geocoder的所有地理编码/反编码能力。
  • 替换操作步骤:
    1. 打开项目根目录的pubspec.yaml文件,删除原有geocoder的依赖条目
    2. 添加geocoding的最新稳定版依赖
    3. 重新执行flutter pub get
    4. 对照新库的接口说明调整原有编码逻辑即可,核心业务代码改动量极小

过渡方案:手动迁移原有geocoder插件适配V2标准(不推荐)

如果项目存在历史包袱暂时无法替换插件,可以手动修改配置适配Android V2 embedding,仅作为临时过渡方案:

  • 打开项目android/app/src/main/AndroidManifest.xml文件,找到application标签,确认已配置android:name="${applicationName}"属性,删除旧版android:name="io.flutter.app.FlutterApplication"配置
  • 找到本地缓存的geocoder插件源码,修改其Android层的插件注册逻辑,适配V2 embedding的注册规范
  • 该方案改动成本高,后续Flutter版本升级仍大概率出现兼容问题,不建议长期使用

临时调试方案:压制警告(禁止在正式项目中使用)

如果仅需临时调试不需要长期维护,可以在gradle.properties中添加配置暂时关闭该警告,但完全无法规避后续Flutter版本升级带来的构建失败风险,仅可用于紧急测试场景。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.01 23:57:00