flutter / flutter-intellij

Flutter Plugin for IntelliJ
https://flutter.dev/using-ide
BSD 3-Clause "New" or "Revised" License
1.98k stars 319 forks source link

Cannot attach debugger #2805

Open Errichamonda opened 5 years ago

Errichamonda commented 5 years ago

Steps to Reproduce

I've already opened a issue on Flutter GitHub but they weren't very useful. When I try to lauch my application in debug mode, it seems like lauching normally. The applicaion skips all the breakpoints without any error and the application doesn't wait for debugger.

Version info

Flutter doctor:

[√] Flutter (Channel beta, v0.10.2, on Microsoft Windows [Versione 10.0.17134.345], locale it-IT)
    • Flutter version 0.10.2 at C:\flutter
    • Framework revision d8cbb80206 (2 weeks ago), 2018-10-26 01:30:21 -0400
    • Engine revision 6c2ade9fa2
    • Dart version 2.1.0-dev.8.0.flutter-bf26f760b1

[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at C:\Users\strez\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[√] Android Studio (version 3.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 30.0.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[√] VS Code (version 1.28.2)
    • VS Code at C:\Users\strez\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 2.20.0

[√] Connected device (1 available)
    • ONEPLUS A6003 • a5e445e6 • android-arm64 • Android 9 (API 28)

Also Flutter Plugin version: 30.0.1

jwren commented 5 years ago

Does debugging work in the samples, but not your your own app?

If it is just your own app, have you happened to modify the main activity for Android? If for instance you modify the call to FlutterMain.ensureInitializationComplete in your Activity, see 1, to not pass the "--start-paused" Dart VM flag, then debugging won't work.

If this isn't it, the next step would be to go look in your IntelliJ logs to see if something is suspect.

Errichamonda commented 5 years ago

The debug works on other project. In the MainActivity.java there is nothing except the usual super.onCreate and GeneratedPluginRegistrant.registerWith(this);

By the way the debugging stopped working in that particular project when I upgraded the flutter plugin from 29. to 30.

The debug seems to work only on the first subfolder of 'lib'. Going deeper it seems like the debugger can't see the breakpoints.

devoncarew commented 5 years ago

@Errichamonda, if you hot reload or restart your app, are breakpoints hit then? Have you modified the native code of the app, or just Flutter/Dart code?

Does this also repro if you create a new (default) Flutter project?

Thanks in advance for the answers!

Errichamonda commented 5 years ago

With flutter clean, hot reload or restart it doesn't hit breakpoints. I've modified only the Flutter Code. Nothing on Manifest, Gradle Settings or other Android folder.

With other project, like the default one that Android Studio creates, the breakpoints works. Only in this application. Probably because the file is nested inside folders.

devoncarew commented 5 years ago

Probably because the file is nested inside folders.

Ah! We may be having path issues. Is the app something you can share with us, or a minimal repro that has the same project structure?

Errichamonda commented 5 years ago

Hi, I've recreated the project with the minimum files to reproduce the problem. https://github.com/Errichamonda/DebuggerTest I've added a breakpoint to the line 17 of lib/ui/main/gallery/main.dart

devoncarew commented 5 years ago

Thanks for the repro case!

I cloned it, added in some necessary iOS files, and opened it in IntelliJ (from the cli, via idea .).

I was able to set and hit breakpoints (in order around line 19 of the above file, and in the setState closure). I'm not sure what's going on in your case, but you may try re-creating the project and see if that helps.

screen shot 2018-11-14 at 8 03 28 am
Errichamonda commented 5 years ago

Oh well, I see now that GitHub removed something from the code, I tried with the breakpoint at line 13

devoncarew commented 5 years ago

OK, that breakpoint worked for me as well.

spagni commented 5 years ago

Hi @Errichamonda! Did you find any solution for this issue? I having the same problems where the breakpoints are not being hit. With other flutter projects it works fine. Is this only project that I can't debug

VyasPrachi commented 5 years ago

Hello, Please give me any solution, My breakpoint is not hit in VS code and Android studio.

Errichamonda commented 5 years ago

@spagni @VyasPrachi Sorry, the problem disappeared after some times and after I changed the project structure to have less subfolder. Probably it's a folder/file name problem.

achtelik commented 4 years ago

Hi, thank you @Errichamonda . I had the same problem and it seems so, that it is realy a naming problem.

I had the class MarkdownSplitter inside the following path: 'package:developer_guide/widgets/MarkdownWidget/MarkdownSplitter.dart' Yes, the name of the folder was "MarkdownWidget" and the filename "MarkdownSplitter.dart".

I wasn't able to debug it via IntelliJ, it only worked via the DevTools webpage.

After changing the folder and file names to the following, the debugging is working via IntelliJ. 'package:developer_guide/widgets/markdown_widget/markdown_splitter.dart'

My flutter doctor: `[√] Flutter (Channel beta, v1.12.13+hotfix.6, on Microsoft Windows [Version 10.0.18362.592], locale de-DE) [√] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [√] Android Studio (version 3.4) [√] IntelliJ IDEA Ultimate Edition (version 2019.3) [!] VS Code (version 1.38.1) X Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [√] Connected device (1 available)

! Doctor found issues in 1 category.`

krupalbhardiya commented 4 years ago

Build: AI-192.7142.36.36.6241897, 202002270544,

AI-192.7142.36.36.6241897, JRE 1.8.0_212-release-1586-b04x64 JetBrains s.r.o, OS Windows 10(amd64) v10.0 , screens 1920x1080

AS: 3.6.1; Kotlin plugin: 1.3.61; Android Gradle Plugin: 3.6.1; Gradle: 5.6.4; NDK: from local.properties: (not specified), latest from SDK: 21.0.6113669; LLDB: LLDB 3.1 (revision: 3.1.4508709); CMake: from local.properties: (not specified), latest from SDK: 3.10.2, from PATH: (not found)

IMPORTANT: Please read https://developer.android.com/studio/report-bugs.html carefully and supply all required information.

Hi, I am facing a probable bug in Android Studio with debugger in Flutter Projects. I have flutter project running with multiple flavors. Flavors are configured in Run configurations and they are running accordingly.

Scenario and readings:

  1. In a complete new Flutter project (Untouched newly created flutter project) after the App is run on device, App runs appropriately. But when clicked on Flutter attach for debugging the App, this is the response debugger shows:

Waiting for a connection from Flutter on Android SDK built for x86 64...

  1. In a multi-flavored Flutter App after App is run on device, App runs appropriately in any of the flavor and build variant. But when clicked on Flutter attach for debugging the App in debug mode, this is the response debugger shows:

Could not find an option named "flavor".

Run 'flutter -h' (or 'flutter -h') for available flutter commands and options.


In any of the scenario, Android Studio cannot attach the debugger in the Device where App is already running. For the note: Debugger is running accordingly when App is directly run from Debug Option(Shift + F9) (instead of Run Option - Shift + F10).

[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18363.657], locale en-US)
• Flutter version 1.12.13+hotfix.8 at D:\flutter_sdk
• Framework revision 0b8abb4724 (5 weeks ago), 2020-02-11 11:44:36 -0800
• Engine revision e1e6ced81d
• Dart version 2.7.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at D:\android_sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-R, build-tools 29.0.3
• ANDROID_HOME = D:\android_sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.

[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] VS Code (version 1.43.1)
• VS Code at C:\Users\Developer\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.8.1

[√] Connected device (1 available)
• Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 10 (API 29) (emulator)

• No issues found!

Annotation 2020-03-20 111924 Annotation 2020-03-20 114213

rodolfoizidoro commented 4 years ago

@krupalbhardiya I have the same problem, do you discovered any solution?

krupalbhardiya commented 4 years ago

@rodolfoizidoro no solution yet.

acoutts commented 4 years ago

I'm also experiencing this in VSCode.

danielgomezrico commented 3 years ago

This is still happening on plugin 53.1.5 and intellij 2020.3.2, it works for iOS but not for android.

Nikitae57 commented 2 years ago

Still happens to me

Bes79 commented 2 years ago

Same issue on all projects on Android and Web. On web breakpoint mark converts from red round to white stop signal.

RudreshNarwal commented 1 year ago

Facing same issue on web and android

tieorange commented 4 months ago

Still the same issue on Android studio and vscode on the latest Flutter version