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

Flutter添加geolocator v11.0.0遇checkDebugDuplicateClasses错误求助

添加geolocator v11.0.0后出现构建错误

在现有Flutter项目中添加geolocator(v11.0.0)包时,一旦将其添加到pubspec.yaml文件中,就会出现以下错误:

FAILURE: Build failed with an exception. Execution failed for task ':app:checkDebugDuplicateClasses'.

为测试问题源于项目本身还是geolocator包,我创建了一个空新项目(代码如下)。新项目原本可正常运行调试,但取消注释pubspec中的#geolocator: ^11.0.0行后,就会出现上述错误。

main.dart

import 'package:flutter/material.dart';

void main() {
  runApp(
    const MaterialApp(
      home: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Geolocator test"),
      ),
      body: const Center(
        child: Text("Hello"),
      ),
    );
  }
}

pubspec.yaml

name: geolocator_test
description: "A new Flutter project."

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
  sdk: '>=3.3.1 <4.0.0'

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.6
  #geolocator: ^11.0.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^3.0.0

flutter:
  uses-material-design: true

环境信息

  • Windows 11 Professional
  • Android Studio Hedgehog 2023.1.1
  • Flutter 3.19.3
  • Dart SDK 3.3.1
  • 调试设备:Pixel 7 API 31虚拟设备

请问我哪里操作有误?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.27 19:52:36