android - Flutter dart 调试器断点停止工作

标签 android debugging dart flutter breakpoints

我正在学习 Dart 和 Flutter,并在 Android Studio 3.1.2 下开发一个小型 Android Flutter 应用。突然调试器断点停止工作 - 以 Debug模式启动的应用程序永远不会在它们上停止,并且指示断点的红点变为内部带有 x 的红点。在我的应用程序中,它们仍然可以工作的唯一地方是 main.dart 模块。

我多次清理了项目,在两种不同的设备上进行了测试,完全卸载了我的 Flutter 调试应用程序,并开始了新的 - 没有任何帮助。 beta(当前 beta 2) channel 上的 Flutter 更新什么都不做。还尝试切换到开发和主 channel - 没有帮助。

有没有人遇到过类似的情况,如何处理?

编辑,添加mail.dart和flutter Doctor的输出(目前在master分支,但切换到beta或dev分支后出现同样的问题):

从 main.dart 导入,或者更好地从 main.dart 导入:

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

import 'app_strings.dart';
import 'net_libs_page/net_libs_page.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: [
        // ... app-specific localization delegate[s] here
        AppLocalizationsDelegate(),
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        //FallbackMaterialLocalisationsDelegate(),
      ],
      supportedLocales: [
        Locale('en', 'US'), // English
        Locale('es', 'ES'), // Spanish
        Locale('pl', 'PL'),
        // ... other locales the app supports
      ],
      title: '@Voice Network Library', //_strings.title,
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or press Run > Flutter Hot Reload in IntelliJ). Notice that the
        // counter didn't reset back to zero; the application is not restarted.
        primarySwatch: Colors.indigo,
      ),
      home: NetLibsPage(),
    );
  }
}

flutter 医生输出:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, v0.4.5-pre.52, on Microsoft Windows [Version 10.0.16299.431], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[√] Android Studio (version 3.1)
[!] IntelliJ IDEA Ultimate Edition (version 2018.1)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code, 32-bit edition (version 1.19.3)
[√] Connected devices (1 available)

! Doctor found issues in 2 categories.

最佳答案

不要在 lib/main.dart

中使用相对导入
import 'app_strings.dart';
import 'net_libs_page/net_libs_page.dart';

改为使用

import 'package:my_app/app_strings.dart';
import 'package:my_app/net_libs_page/net_libs_page.dart';

其中 my_apppubspec.yamlname: 字段中的内容。

跟踪的问题https://github.com/dart-lang/sdk/issues/33076

关于android - Flutter dart 调试器断点停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50425430/

相关文章:

java - 如何转换 XML 以在 Android Java 中以编程方式查看

android - 使用 OpenGL 的视频帧旋转

android - 如何通过 ACTION_VIDEO_CAPTURE 操作将文件输出设置为 mp4?

flutter - flutter 柱删除空间之间的子项

flutter - 如何在 flutter 中创建带有透明孔的小部件

dart - flutter/dart 中的 '._' 约定是什么?

c# - 单声道不能消费触摸事件

debugging - 调试器创建教程

node.js - 在 AppFog 上,如何在终端 (node.js) 上查看控制台日志

c++ - 调试混合 JNI 代码的方法?