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

Flutter模板App通过USB调试运行Android设备时出现多类错误求助

Flutter USB调试运行模板App报错排查

我是Flutter新手,尝试通过USB调试模式在Android设备上运行一个模板App,但点击“运行”后控制台输出了多个错误,不清楚这些错误的含义及修复方法,希望有人帮忙排查并指导如何让App正常运行。

输出日志

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
../../AppData/Local/Pub/Cache/hosted/pub.dev/firebase_auth-3.4.0/lib/src/firebase_auth.dart:589:23: Error: The method 'signInWithAuthProvider' isn't defined for the class 'FirebaseAuthPlatform'.
 - 'FirebaseAuthPlatform' is from 'package:firebase_auth_platform_interface/src/platform_interface/platform_interface_firebase_auth.dart' ('../../AppData/Local/Pub/Cache/hosted/pub.dev/firebase_auth_platform_interface-6.10.0/lib/src/platform_interface/platform_interface_firebase_auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'signInWithAuthProvider'.
      await _delegate.signInWithAuthProvider(provider),
                      ^^^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dev/firebase_auth-3.4.0/lib/src/recaptcha_verifier.dart:57:27: Error: Required named parameter 'auth' must be provided.
      _factory.delegateFor(
                          ^
Target kernel_snapshot failed: Exception


FAILURE: Build failed with an exception.

* Where:
Script 'C:\flutter_windows_3.7.8-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1151

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter_windows_3.7.8-stable\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
Exception: Gradle task assembleDebug failed with exit code 1

使用的版本信息

  • Flutter 3.7.8(稳定通道)
  • Framework 修订版本:90c64ed42b(发布于2023-03-21)
  • Engine 修订版本:9aa7816315
  • Dart 2.19.5
  • DevTools 2.20.1

错误分析与修复步骤

前面的XML命名空间警告属于Gradle兼容性提示,不影响编译,可直接忽略。真正导致编译失败的是两个核心错误:

  1. signInWithAuthProvider方法未定义:firebase_auth包(3.4.0版本)和其依赖的firebase_auth_platform_interface(6.10.0版本)存在版本不兼容,旧版本的firebase_auth调用了新版本接口中已移除的方法。
  2. delegateFor缺少必填参数auth:同样是版本不匹配导致的参数定义不一致问题。

修复操作:

  • 打开项目根目录的pubspec.yaml文件,找到firebase_auth依赖项,将版本号更新为与Flutter 3.7.8兼容的稳定版本(建议使用^4.6.0或更高),示例:
    dependencies:
      firebase_auth: ^4.6.0
    
  • 执行命令更新依赖:
    flutter pub get
    
  • 清理项目缓存并重新构建:
    flutter clean
    flutter pub get
    flutter run
    
  • 额外确认:检查Android设备的USB调试已开启,且电脑能通过adb devices命令识别到设备。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 08:45:00