Android Studio IDE: how to debug through my code only in Flutter? - android-studio

In Android Studio, I want to debug only my code, but step in to keep taking into dependency library. I see question , also , but they don't solve the problem. I could not find a way to not debug into message_codecs.dart, message_codecs.dart or method_channel_firebase_auth.dart (firebase_auth_platform_interface-1.1.2). I also looked that I can disable or enable all exception , but that is what I don't want.
I simply don't want to step in to these system( dependencies) library. Please let me know if there is any solution.

Go to VS Code user settings. On mac you get to VS Code settings by clicking CMD + ,
2A. Then you search for debugSdkLibraries and dart.debugExternalLibraries and make sure they are unchecked.
2B. Or you can edit your settings in JSON file by adding this:
"dart.debugSdkLibraries": false,
"dart.debugExternalLibraries": false,
E.g. here is my full settings file: https://gist.github.com/tomasbaran/cd0ba7cadec4466356d1dc0faa14f1e2

Right click on a Breakpoint.
Click on "More"
Uncheck "Dart Exception Breakpoint" checkbox
Added screenshot below for reference.
https://i.stack.imgur.com/GdMnp.png

When you're debugging and the code on the next line will go into something that you didn't write, Step-Over instead of Step-Into.
Step-Over will execute until the call stack is in the same state and the line you were on has finished execution.

In vscode you can configure it with "Dart: Debug External Libraries"

Related

Flutter disable system debug messages in Run Tab

I use:
print('Pls. show this line only');
to debug my flutter apps developed by Android Studio. However, the output in the [Run Tab] is usually something like:
Tens/Hundreds of system debug messages
I/flutter ( 9154): Pls. show this line only
Tens/Hundreds of system debug messages
OK, sometimes it takes me minutes to find my own debug message [Pls. show this line only].
My question is simple, how can we disable [Tens/Hundreds of system debug messages] in the Run Tab of Flutter Project in Android Studio?
Meanwhile, I am using:
print('***************************************************** Pls. show this line only');
as a work around.
In Android Studio....
Before
Settings
File > Settings > Editor > General > Console
Look for section:
Fold console lines that contain
Click the + button on right hand side of scrollable list
Add your substring of what you'd like hidden from the Console output.
For example in Flutter, I'd remove D/ (i.e. letter D + forward slash) which are emulator debug messages.
After
I Finally found a Workaround For VS code this is NOT permanent so you have to do it once per session but it helps a lot ...
there is a hidden feature in vs code for debug log filtering and all you need to do is to filter the log to have only the flutter related logs as follows :
1) focus on debug console (by clicking on it )
2) click ctrl + f (nothing will appear but you are now in filtering mode)
3) Type "I/Flutter"
4) hover on the word and click the icon next to it to make it stick .
that's it !
Before :
After:
In Android Studio:
select text you want to ignore in the console
Right-click it
Fold lines like this
Android Studio Flutter Console folding
Select the option as shown in case IntelliJ IDEs or Android Studio
Now you can filter as follows
The android-studio 4.0 has a setting to make this messages go away.
Go to File -> Settings -> Languages and Frameworks -> Flutter
Uncheck the box stating Enable verbose logging
Settings View
Add
I/flutter
in filter of VsCode Debug Console Filter.
Rather than filtering the logs, use the release version of the drivers :
flutter run --release
This will avoid printing all the system logs like :
V/MediaPlayerNative(22395): playback complete
And your debug prints will continue to display.
Drawback is you won't use anymore the hot reload. Reserved to investigate when the debug prints are flooded in system logs.
Of course applicable to VSCode.

Using Resharper to compile the source cant hit the breakpoint

When I use Resharper to compile my source that I always cant hit the breakpoint and the Visual Studio say that
The breakpoint will not currently be hit. The source code is different from the original version.
I must click the rebuild button to rebuild the source to hit it.
Can anyone give me some way to make the resharper to build the source well?
I don't want to do some step when I want to run app than press F5.
This may be a result of perceived differences between the source code and compiled debugging symbols. I'm not sure if this will help, but you could try allowing slightly different source code when debugging. Untick the option as shown...
Tools > Options > Debugging

Visual Studio 2013 Edit and Continue not working

With VS2013 Pro I am not able to use "Edit and Continue" when debugging an MFC program. I created a new MFC project to test.
OS is Windows 7 64-bit and I'm running Visual Studio 2013 12.0.30110.00 Update1.
Under Tools->Options->Debugging->Edit and Continue I have Enable Edit and Continue checked. I have unchecked it and checked it, but whenever I modify the code while debugging I get the following message:
The source file has changed. It no longer matches the version of the file used to build the application being debugged.
Basically I haven't changed any settings except for the tab sizes and I've set the keyboard mapping scheme to VC6.
What setting am I missing to enable edit and continue?
Edit and Continue is disabled for native code by default. To enable:
On the Tools menu, click Options.
In the Options dialog box, open the Debugging node, and select the Edit and Continue category.
In the Native-only options group, select Enable native Edit and Continue
Edit:
Steps to test native Edit and Continue is working:
Start VS 2013
Create a new MFC project:
FILE->New Project->MFC Application->OK.
Select Finish on the MFC Application Wizard.
Build and start debugging:
BUILD->Build Solution
DEBUG->Start Debugging
Break into the program:
DEBUG->Break all
Make a code change:
Open OutputWnd.cpp and find COutputWnd::OnSize (Line 80)
Insert this line at the start of the function: cx = cx / 2;
Continue execution:
DEBUG->Continue
Resize the application window to see the effect of the code change on the Output pane at the bottom. Its width should be half the required size.
Edit and continue is also a Setting for each project.
It must be set in the compiler options under C++ -> General -> Debug Information Format: "Program Database for Edit And Continue (/ZI)"
Also the linker settings must be changed. The linker has to use incremental linking. Linker -> General -> Enable Incremental Linking = Yes or (for VC 2012 users) C++ -> All Options -> Enable Function-Level Linking = Yes (/Gy)
For more information read the MSDN.
The last hint helped, but we had to
set "Image Has Safe exception handlers" = NO(/SAFESEH:NO)
in all projects of our solution!
I did all steps described above, but nothing helps (thanks all for it).
My solution was:
Project -> Properties -> Linker -> Advanced:
set
"Image Has Safe exception handlers" = NO(/SAFESEH:NO)
Apply, Ok, and Rebuild project.
Hope it helps.
For what it's worth I've been pulling my hair out on this one as well. I finally got edit and continue working by changing the following setting:
Project > Properties > Linker > All Options > "image has safe exception handlers".
It was set to No (/SAFESEH:NO). I went in and deleted it. I didn't set it to YES, or NO. I simply kept it blank. I would love to know what it means to be blank. But edit and continue is now working for me. Maybe it will help for you.
A project with a "Release Configuration" will disable Edit and Continue.
To change this
Open "Configuration Manager"
Change Configuration for the project from Release to Debug
Rebuild and debug project
Edit and Continue will also not work if your project's Platform Toolset is set to Visual Studio 2012 (v110), instead of the usual Visual Studio 2013 (v120).
This setting is in Project > Configuration Properties > General > Platform Toolset.
The solution of this problem is on the Microsoft Documentation...
If IntelliTrace is enabled and you collect both IntelliTrace events and call information, Edit and Continue is disabled.
On Visual studios' menu go on Tools>>options - Select "IntelliTrace" tab and let IntelliTrace events only checked.. Save, restart the visual studio and.......
Your Edit and Continue will work again!

Android Studio - Auto complete and other features not working

I installed android studio.. it was working fine. Now all the sudden, none of the auto complete features are working.. I can type anything anywhere no variable checking, no help with functions or checking anything. I can still compile the project and I get errors when that happens.
Can anyone please help me out with this issue.
#1 From Build menu (of your Android Studio), click Rebuild Project option.
#2 Then once rebuild completes, go to File > Invalidate Caches / Restart... and Click on Invalidate an Restart button.
This really works for me.
Source: https://code.google.com/p/android/issues/detail?id=61844#c4
#1 Rebuild is required, because Android-Studio does simply rely solely on Gradle's build-result (without static-analysis support, at least at time of writing, 2022).
#2 Clearing cache is required, because the previous build-result (before above rebuild) may be indexed, which makes Android Studio ignore latest Gradle build-result
(this is a very good speed optimization, but a very bad Developer-experience as well).
There can sometimes be other reasons too, which is why there are many other answers posted here.
You can also check if Power Save Mode on File menu is disabled.
Close Android Studio
Go to C:\Users\UserName\.android and rename the folder:
build-cache to build-cache_old
Go to C:\Users\UserName\.AndroidStudio3.x\system
OR (for Android studio 4 and Higher) go to C:\Users\UserName\AppData\Local\Google\AndroidStudio4.x
and rename these folders:
caches to caches_old
compiler to compiler_old
compile-server to compile-server_old
conversion to conversion_old
external_build_system to external_build_system_old
frameworks to frameworks_old
gradle to gradle_old
resource_folder_cache to resource_folder_cache_old
Open Android Studio and open your project again.
Originally use:
compileSdkVersion 32
targetSdkVersion 32
And an update to 33 appeared, I updated it and the suggestions in the XML no longer appeared, I went back to 32 and now the suggestions appeared.
Close Android Studio
Go to c_users_path_on_windows/.AndroidStudio3.5/system/
Delete the cache folder
Start Android Studio
This works for me.
Most of the times i have seen that the problem is that Power Save Mode is enabled, to disable go to Current inspection profile (lower right corner in Android Studio).
I have not run into this problem personally, but try checking the following settings (File -> Settings or Alt+F7):
Project Settings [name]
Inspections - ensure that Android and Android Lint is checked, or alternately just set it back to default using the dropdown box at the top.
IDE Settings
Editor -> Code Completion - ensure the Autopopup code completion is checked (and check the rest of the settings based on your preference.
Uncheck "Power Save Mode" in "File" tab
If nothing works (like happened with me ) go to your user profile in windows at %userprofile% . You will find folders there (hidden) named with the version of the android studio you are using and prefixed with a dot.
like .AndroidStudio3.1. Just delete that .
Solution: Try disabling "File -> Power Save Mode" in Android Studio (Beta) 0.8.14 - Mac OS X
On windows, the option can be at some other place.
I had the same problem then I recalled that while exploring the new android studio, I switched on the "File -> Power Save Mode" to see what it does?
I disabled the power save mode and all those intelligent features were back.
It turned out that in Power Save Mode, Android Studio switches off the modules responsible for features like Smart Code Completion and Code Analysis.
I had a similar problem where none of the other solutions worked.
Closing Android Studio and then deleting the .idea and build folders resolved the issue.
Disable Power Save Mode and Invalidate Cache and Restart.
For Artic Fox 2020|3.1 Version: Auto Complete Suggestion Problem.
Please Follow the Following Steps:
Close Android Studio
Locate caches folder in C:\Users{username}\AppData\Local\Google\AndroidStudio2020.3
and Delete it.
Open Android Studio Again.
Check your Android studio version and Target that version folder at below location
C:\Users{username}\AppData\Local\Google
Note : AppData folder is Hidden in Windows
This Solution also works if android studio mess up with xml files and java code. Don't! modify your code otherwise IDE won't able to change it to default. If you see such messy code just follow above steps and your code will be fine again.
It's Working
Disable Power Save Mode
Untick Power Save Mode Option ::
File -> Power Save Mode
There is a power saver mode in android studio if accidentally you click on that it will disable code analysis which will reduce the battery consumption and performance will also increase but it will not detect any errors and do auto complete operations.
To disable power saver mode
- Go to File Menu of Studio
- Uncheck The Power Saver Mode
In your IDE code analysis will be shown using an eye symbol at the right corner of your android studio.
If Green means it is enabled and there is no error in your code.
If Red Means It is enabled but there are few errors in your code.
If It is white or blur then code analysis is disabled
Just remove all the folders named AndroidStudioPreview
On Windows:
Go to your User Folder - on Windows 7/8 this would be:
[SYSDRIVE]:\Users[your username] (ex. C:\Users\JohnDoe)
In this folder there should be a folder called .AndroidStudioPreview
On Mac OS X
Remove these files:
~/Library/Application Support/AndroidStudioPreview
~/Library/Caches/AndroidStudioPreview
~/Library/Logs/AndroidStudioPreview
~/Library/Preferences/AndroidStudioPreview
There can be several things which cause this.
Make sure you've write the correct version in targetSdkVersion and compileSdkVersion.
Make sure targetSdkVersion and compileSdkVersion are same.
Other solutions can be:
Invalidate caches & restart Android Studio from File → Invalidate Caches / Restarts...
Clean your project from Build → Clean Project
Rebuild project from Build → Rebuild Project
Make project from Build → Make Project [this process may take some time]
Be sure to check for IDE errors by clicking the button at the bottom right of android studio.
In my case, there was a bad plugin, and the IDE Fatal Errors window prompted me to uninstall the plugin. (I wish I'd known about this feature before spending half a day invalidating caches, deleting folders, and reinstalling android studio with no luck.)
It worked for me.
From menu select:
File -> Power Save Mode
and make sure it's disabled
Go TO Left Side Top File Option
Then Click To Power Save Mode
Disable Power Save Mode That Fix This Issue
In my case, when I switch keyboard language to English, the auto complete works again.
if the autocomplete isn't working for you in Android Studio, just press File and uncheck the Power save mode, it should work fine after that.
if power save mode is already unchecked then first check then uncheck them.
If you have a library project included, make sure the library has the dependencies in build.gradle listed using the api configuration, not the implementation configuration.
Also make sure that the project that includes the library has all the dependencies listed (using the implementation configuration is fine here).
'The file size (2561270 bytes) exceeds configured limit (2560000 bytes). Code insight features are not available.'
Had this issue for days with none of these proposed solutions working before eventually getting this message in yellow under the tabs after adding a line of code. Removing the line of code eliminated the message but not the issue. There appears to be a code size window where you lose insight features but don't get this message, at least for me. Once you go over a certain point the message finally pops up. The suggested solution in a different thread for this issue was to edit 'Help/Edit Custom Properties' to increase the configured limit, but just opening this brought up a dialogue asking if I wanted to create an 'idea.properties' folder so I decided not to risk that approach over eventually cutting the file size.
If sometimes this problem can occur if you misspelled a file extension or make a file without adding an extension.
Check you have added the file extension correctly.
I think that answer may help you.
I'm using mac and suddenly the code completion (^space) not working. There are no errors. Turned out the android studio's shortcut was conflicted with system's shortcut. I don't know why it suddenly happen because it was fine before, maybe there was an update on my Mac.
See below setting for the conflicting shortcut
In my case, C:\Users\UserName\AppData\Local\Google\AndroidStudio2020.3\ just delete caches folder and restart android studio. after deleting this caches folder my problem was solved :)
I encounter with this problem while adding a kotlin library into my project on mac. Changing macbook language to english solved this problem. I also had some weird problems with auto-generated databinding codes, those are also solved.
Try Invalidate caches/Restart from File in Menu Bar from android studio.
Close Android Studio
Go to
C:\Users\YOUR_USERNAME\.android
and rename the following folder to:
build-cache to build-cache_old
then Go to (Android studio lower then version 4)
C:\Users\UserName.AndroidStudio3.x\system
OR (Android studio 4 and Higher) Go to
C:\Users\UserName\AppData\Local\Google\AndroidStudio4.x
or
C:\Users\UserName\AppData\Local\Google\AndroidStudio2021.2
depending on your version and rename these folders:
caches to caches_old
compiler to compiler_old
compile-server to compile-server_old
conversion to conversion_old
external_build_system to external_build_system_old
frameworks to frameworks_old
gradle to gradle_old (if exists)
resource_folder_cache to resource_folder_cache_old (if exists)
Open Android Studio again and the autosuggsion will be fixed.
and You can also check if Power Save Mode is disabled or not from the File menu.

Where is the warnings screen option in Android Studio?

I want to see warnings of my code in Android Studio, But i am unable to find the option to display warnings view. In case of eclipse we can see the warnings in the "Problems" view.
Can anyone suggest me, how to view warnings in android studio?
If, on the toolbar, you click Analyze -> Inspect Code; then in the window that pops up select how much of your project you want to inspect (I usually do Whole Project, but you might want to select a specific module), then click okay.
Android Studio will work for a bit, then the inspection window will pop up from the bottom with a list of results, subdivided by inspection.
Build -> Make Project (Ctrl + F9) gives what we can get equivalent of Eclipse's “Problems” view on Android Studio
you can use F2 to next problems, see more here: Navigating to Next/Previous Error
GO to View-->Tool Windows-->Messages to view the warnings
Even i searched all the settings in Android Studio, but couldn't find a separate window for it.
The warnings are actually visible to the right end of a particular line as a small yellow marker and clicking on that show the warnings in the status bar below. The colors of them can be editted in the inspection options.
Hope this helps you.
The closest thing Android Studio/IntelliJ has to the Problems view in Eclipse is to use the Problems section of the Project tool window. With that open, navigate down to any classes that appear there and open them in the editor. Once in the editor, you can use F2 to jump between errors in the open file.
Unfortunately, IntelliJ's Problems tool window shows classes with errors nested by folder/package, so you have to expand several levels and it takes up a lot of screen real estate to see even one error. It also doesn't list the errors individually, forcing you to first open the problematic file and then use F2 to navigate to each one. I also had the problem that errors in files that weren't open, didn't show up there.
[opening warning screen in android studio
Click the warning icon as marked in the image.
Warning screen will open.
][click to see image] here

Resources