Editor Opens main.dart on Save - android-studio

Have a flutter web project being developed using Android Studio and something has changed recently which is now causing Android Studio to open up the file main.dart in the editor pane whenever a file is saved while the project is running in chrome.
Say the project is made up of two dart files: main.dart and example.dart and I have only the file example.dart open in the editor. I then click run 'main.dart which causes the application to launch in chrome browser. If I then make a change in example.dart while the app is running and save the file, the main.dart file is automatically opened in Android Studio's editor pane and gets the focus. This is forcing me to have to switch back to the example.dart file each time I want to make another change to it.
Not sure if it is Android Studio doing this or flutter itself as part of its hot reload functionality. Or maybe something I clicked on by mistake making it do this?

Did a flutter upgrade and the issue has now gone away so maybe the problem was somewhere in flutter web's Hot Reload functionality.

Related

Infinite app closing issue in android studio

I have just changed the package name in the android studio, and also replaced the new google-services.json file downloaded from the firebase console to configure the new package. After these changes, the application is installed properly on the emulator but it is displaying just a white screen and not moving to the splash screen. Even, It is not going to Launcher activity, I have tried to debug by putting the breakpoints. In the logcat of the android studio, it seems it is closing and opening in infinite ways. I have also attached the screenshots here.

How to open an existing Flutter Project in Android Studio

I might sound noob here but I can't see a clear way of opening existing Flutter Project in Android Studio 3.1.2.
I checked this but it didn't work. So I want to know if there is a standard IDE way of doing this? I also can't find any docs clearly mentioning it. Do I need to install a 3rd party plugin?
After opening it as an Existing Android Studio Project, I get the following error:
The error is solved by running Get Dependencies. Is it a normal behavior?
Install Flutter plugin for Android studio: https://flutter.io/get-started/editor/
Open Android Studio
Open existing Android Studio project by using one of below methods:
EASIEST WAY: Drag your project folder and drop to Android Studio.
Other ways:
What works for me was to open existing Android Studio project like mentioned above, and then go to menu
Tools -> Flutter -> Flutter Clean
Then configuration window will open and ask you to locate flutter sdk. After locating the sdk, click OK and then the flutter functions will be available (Pub buttons, runs menu). After that you can proceed to get the dependencies (pub get).
It's basically cleaning the project folder of previous setting(s) which might conflicting with the system (android studio). But that won't happen if you get the project from source repository because all of the junk files wont be in the project folder.
The quickest way on macOS is
open -a Android\ Studio android when you are in the root project directory.
Alternatively, if you use the jetbrains toolbox, you can enable "Shell Scripts" in its settings. This will create a binary in the folder of your choice, so you have to add this folder to your PATH. Then, you can use studio . inside the Android folder, or studio android in the flutter project. The benefit of this, is it also works with other Jetbrains products (e.g. charm project_dir or clion project_dir. Unfortunately this method glitches out (for pycharm at least).
Looks like Android Studio can't load Android Application module from Flutter project automatically. I also have same problem, so in my situation Gradle can't be found, because of lack of Android project.
There's important note from official site:
Important: Do not use the New > Project from existing sources option for Flutter projects
I suggest, same is for Open option.
Just Open your project as normal, and then in [Android Studio > Preferences > Languages&Frameworks > Flutter > Flutter SDK path] select the path where you downloaded & unpacked Flutter SDK.
I know it's already late, but you can open an existing Flutter project in Android Studio by following these steps (make sure you have already installed Flutter & Dart plugin and Flutter SDK):
Click Open from File menu in Android Studio,
Go to the path of the project,
Click Open from the dialog,
When the project opens in Android studio, it will show an error of packages and dependencies. So, click on Get Dependencies on the top. Android Studio will automatically add all the required dependencies and packages.
There is a simple way of doing this in android:
Just Open your project as normal, and on the top right corner, click on Flutter Attach option, and voila!
See Attached screen grab!
Usually you can open your Flutter project in Android Studio simply when you right click on the android folder > Flutter > Open Android module in Android Studio but sometimes this option could be disabled, check this answer to enable..

Android Studio 2.2.3: Favorites, bookmarks and opened folders keep disappearing, project and .idea-folder are always rebuilt

I'm trying to use favorites and bookmarks with Android Studio 2.2.3 on Windows 7 in order to navigate through our code base.
I have openend one project, where the saving of favourites and bookmarks works fine. BUT when I open another project, while my first project is open as well and then close one of the 2 projects, the closed project loses all the favorites, bookmarks and which folders and tabs I had opened.
Also AS keeps asking me to add the VCS root everytime I start it.
Although I've searched I could not find any sources describing my problem.
I've copied all my projects into a new folder and gave myself all permissions to this folder, which did not fix my problem, so I think permissions are not the problem.
My assumption was, that Android Studio might have trouble if you use multiple instances.
So I went and tried to set it to only use one window:
But this setting keeps getting ignored and AS opens a new window for every project.
I reset all the settings for Android Studio by removing the folder C:\<username>\.AndroidStudio2.2.
Then I re-started Android Studio and didnt import any new settings.
With this configuration my problem still occurred.
In order to reproduce the 'bug' do this:
Open a project by File -> Open (NOT File -> Open recent!)
Add bookmarks
Open another project (while the first project is still open!) by File -> Open
Add bookmarks there as well
Close project 1 and re-open project 1 by File -> Open
All tabs / bookmarks / favorites should be gone at this point.
Vadim Kotov has confirmed that the problem happens with his Android Studio as well, so I suspect a bug in AS.
How can I fix the disappearing favorites, bookmarks, opened folders and tabs?
This problem seems to be a rather old bug in Android Studio:
https://code.google.com/p/android/issues/detail?id=172347
The bug is fixed in the Android Studio 2.3 BETA-release:
https://code.google.com/p/android/issues/detail?id=232670&thanks=232670&ts=1485023505
Basically Android Studio seems to overwrite the workspace.xml in the .idea-folder for a project with a default - workspace.xml everytime I use the Open - menu.
AS probably re-creates the whole .idea-folder and rebuilds the project, everytime I use the File -> Open-dialog.
Workaround:
Since I cant switch to another version of Android Studio due to company rules, I use the following workaround:
When you want to open a project for the first time, you have to use File -> Open
After that, ONLY use File -> Open recent in order to get into one of your projects
This will save the opened tabs, bookmarks, favorites and will open only one instance of AS in the forground instead of the background.
WARNING!
If you later click on File -> Open either because the recent-menu is filled too much, or you do it by accident, you still probably will lose your bookmarks, favorites etc...

Android Studio Project Structure has changed

Usually when I open my Android Studios and I click on new project it then comes up with another page that asks you to enter Application name: etc...Something has changed somewhere for some reason because that doesn't come up. If I click on a recent project it opens up but at the top left hand corner where you can change the view to project, package, Android etc. Android is no longer in there and the drop down options are now Project, Packages, Scratch, Problems etc. How can I get back the normal view? Or can someone tell me what could have caused this issue?
Thanks!
Just restore Studio default layout by Shift+F12

Project that I just opened "could not be opened"?

I have a VS2012 C++ project. I can open the project by clicking on the .sln file, but when I open VS2012 and try to open the project from the Start Page, I get this message:
"TestApp2" could not be opened.
Do you want to remove the reference(s) to it from the Recent list(s)?
I don't get this message for all projects, just this one.
I'm trying to run it from the Start Page because I want to run the code as an Administrator. I can right-click the VS2012 icon in the Start Menu and click "Run as Administrator", but right-clicking the .sln doesn't provide this option.
Is there something I can do to fix the project so it can be opened from the Start Page? Or is there another way to open the project as an Administrator?
The link that is stored in the memory for Visual Studio, is now different. This is the only way that could happen. So, remove it from the pinned recent solutions, open it manually, and then it will have the correct linkage in the Visual Studio menu.
Sorry, didn't see prior post on same solution. :)

Resources