Android studio not showing project files - flutter

Please I have been working on a flutter project on android studio, and at one point I found myself with this situation, the project files on the left is not showing, there is this loading icon
enter image description here

Android Studio started opening my Flutter project as an Android-only project for some reason. Deleting the .idea folder at the Flutter project root removes all the IDE settings. Reopening the project after that fixed it for me.

Change that Android on top Left to Project i think this will fix it

Invalidating cache and restart will solve your problem.
From the main menu, select File | Invalidate Caches.
Click Invalidate and Restart.

Related

i get "Error running 'main.dart': Entrypoint isn't within a Flutter pub root" every time i try to run my app

i'm working on app using flutter and android studio this is the error I get every time i try to run my app
i tired running other projects and they ran completely fine
This could be due to a failed rebuild.
Click on File at the top left corner on the menu bar.
Click Project Structure
Click on Module at the left end, then click on sources.
You will then see your project directory below the language level. Ensure that this path is correct and points to the root folder of your project. That is the project folder. If not update it and click Ok at the bottom of the dialog.
On the menu bar click on Build then rebuild project.
I have encountered this issue recently and I don't know how or why but I somehow my main.dart file was no longer listed as a dart file - I Resolved this by right clicking the main.dart file in Android Studio. Clicked the menu option that populates 'Mark as Dart' afterwards no issues - it compiled and a lot less hair for me.
I was having this issue and tried everything and nothing was working.
Then i realised that the pubspec.yaml was not there. So i restored it with git and poof everything was working again.
It was deleted (but not committed) and restored I it with git checkout HEAD pubspec.yaml in my case

how to fix android studio changing flutter code

There is something weird is happening in my Android Studio it changes code views, for example, I wrote a normal code and it works fine but when I want to see my code it is full of things that are not my code
it does the same to flutter itself codes
this is Flutter Container Code...it works but I can't see the code... and it is fine in VsCode
thanks in advance.
Try changing font settings as default in Android Studio.
From menu bar, File > Invalidate Caches & Restart, to clean cache and open files again.
just copy project folder and paste to other folder directory.
suppose your project is kept. and copy project folder from below folder
C:/myflutterproject
create new project directory and paste project into new folder.
C:/newmyflutterdirectory
open project from new folder.
C:/newmyflutterdirectory

Cannot do new Image Asset in res folder

I want to do a new Image Asset in my res folder in my flutter project, to change the layout of my app icon. However when i right click on the res folder and chose New -> 'Image Asset' is no longer an option in my Android Studio... Anyone who knows how to fix this? I've been able to do it before. I've updated the Flutter plugin, but that didn't make any difference.
I'm new to flutter as well and as part of following the flutter course, ran into the same issue.
The following solution is with android studio version
Android Studio Arctic Fox | 2020.3.1 Patch 3
Build #AI-203.7717.56.2031.7784292, built on October 1, 2021
Runtime version: 11.0.10+0-b96-7281165 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.0.1
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 12
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: Dart, io.flutter
I found the 'Image Asset' option by following the below-listed steps
Right-click on the 'res' folder
Hover over 'Flutter' option and click 'Open Android module in Android Studio'
When a pop-up asks 'Where would you like to open the project?', select 'New Window'
Once the project opens in new window, expand the app directory to find 'res' folder.
Right-click on 'res' folder, click 'new' and you'll now see the Image Asset option
I want to clarify these answers, it's all there, but it's too confusing: You must create an images folder in the project. In most of my projects, I would create an assets folder, and then a subfolder of images. This won't work, must be a top level images folder.
Additionally, if you start your project in VS code. You have to start the project in Android Studio. You can always just start a new project, do your icon work and copy the folders over to your actual project.
But TWO things seem to interfere: If you don't have an images folder and if you did anything in VS code. I was guilty of both, and had to unwind both issues.
Start a new project in Android Studio
Create an images folder.
Add it to your pubspec.yaml in assets: Mine would look like this:
assets:
assets/images/
assets/sounds/
assets/
images/
Now you'll be able to right click on the res folder and see new image asset.
Do your icon work.
Copy the res folder over to your actual project.
Want to iterate: I put an image in the top level images folder, but I don't think it even needs that. It is looking for the folder, and you must have it. Somewhere in the code, a top level images folder is a condition to giving the image option.
Starting in Android studio will give the option, but it's greyed out.
Having the images folder is the magic key that opens the hidden door.
Go to menu file > open.... select android folder and click open.
wait until it finished loading then try to right click res folder again.
The Image asset menu will be shown.
discussion on this issue.
https://github.com/flutter/flutter-intellij/issues/3512
open android studio File->Open folder->navigate to your flutter project and select the Android folder. Wait for it to sync, then navigate inside the Android studio folder and find the res folder right click on it and choose New you will see the Image asset studio.
In the flutter project, the option won't be available...You can right-click on the android folder and go to the flutter menu and click the open project in Android Studio Option...Then the android project of your flutter project will be opened as an individual project...There you can use all the android studio's native functionalities.
It was not working for me as well. I cleared the build using flutter clean and the option was available after that.
Right click in res>Flutter>Open Android module in Android Studio
You will be able to see the image asset option after android module has opened in android studio.

i couldn't open existing flutter project

i have been imported flutter project and it worked well ,but i faced this problem when i tried to open it again.the project folders is not accessible as in the images
[]
[]
,thus when tried to run the project from terminal i get the error that referred to in the image one.
note:
the flutter path is set as in []
In your android Studio, right side you have "gradle" and "Flutter outlie" views. Out of which click on gradle. then right click on your root project and select "sync project with gradle files"
Then enable dart support in your project. To enable dart Go to File > Settings > Language & Frameworks > Dart > Enable Dart Support
This will solve your issue.

Error: Entrypoint isn't within the current project

Unable to run flutter from Android Studio not detecting flutter project its shows Error: Entry point isn't within the current project
Every time restart android studio same error message shows
Delete the .idea folder inside the root of the flutter project and restart Android Studio.
Refer to this question: What is the .idea folder? and make your decision if it's safe or not to delete .idea folder.
Click on File-> Project Structure -> Module then add root folder of
your project then it will detect its a flutter app and then build and
work
its work for me
Reference: https://github.com/flutter/flutter-intellij/issues/2307
1) make sure flutter and dart sdk paths are properly configured from
File-> Settings..->Languages and Frameworks
as well as make sure Dart support is enabled for project module from Dart Option
2) at the end select File->Invalid caches and restart
3) so after 2nd step you may get in File->Project Structure.. option from there Select Modules then just simply add only root folder path of your flutter project and repeat just above 2nd step
for me this worked
Syncing your project with gradle files will solve it:
You can sync the files with Gradle, within the File menu.
Else You can re-include the files/project root folder inside the File Menu.
File -> Project Structure -> Module
And then add the root folder of the project(with + icon), then it will detect that it's a flutter app again, and then build and work again.
Try delete .idea folder inside project folder and Invalidate & Restart Android Studio.
For me my project was missing the pubspec.yaml file, it was deleted by mistake , instead of warning about the missing file , I got this error
This problem happened to me
I solved it this way
Go to the Android Studio track
I have this way
C:\Users\mustafamaxL\.AndroidStudio4.0\system
Remove folder (caches)
Then, start Android Studio again
If your ios, android, or lib folders are missing, it typically means there is something wrong with your project structure.
To fix it, delete the .idea folder in the root of your project and then restart Android Studio. If you're using a Mac, you can display the hidden .idea folder by pressing Command+Shift+Dot in Finder.
The .idea folder will be automatically regenerated and everything should be back where it belongs.
See this post for the original solution.
Click Content Root Close Icon and Remove Android Folder.
Fix it to me.
I faced the same issue today and tried other solutions here but it wasn't worked at all.
In my case I deleted three folders that is android, ios, and .idea from project directory, then restarted android studio and finally I gave this command in Android Studio's Terminal.flutter create . to create appropriate directories (i.e., android & ios).
Now it is working fine.
Note: Before deleting the android / ios directory please make a backup of these directories only if you previously gave native code in android / ios directory.
Hope this solution will helpful if others will not work.
The .idea folder will also be deleted on Linux. When Andriod Studio opens, click terminal at the bottom in Android Studio. Then type remove -r .idea/ in the terminal and press enter. After deleting, close and restart Android Studio.
You might need to update the Gradle version. Or change the minimum android SDK version.
Here is worked for me:
Update Gradle / minSdkVersion version
Reopen the project but at the directory user/StudioProjects/yourFlutterApp/android.
After it is opened it will load some packages (see right bottom), which will take some time.
It will ask you to update the Gradle version (right-left corner) or go under File>Project Structure Project you can set a higher Gradle version and under Modules variables of your build
Now you can sync your project with Gradle files
After configuration, you might need to restart your project with File>Invalid Caches/Restart....
I have created 2 folders inside lib's folder for my *pages* and *widgets*.
Getting the main.dart file back to the **lib folder** will do the trick
I'm currently in Android Studio Electric Eel.
I've done all of the suggested solutions above, but nothing works.
Turns out the project is not detected as a Flutter project. So what I do to resolve this issue is to remove gradle-related files from the root folder:
build.gradle
gradlew
gradlew.bat
gradle/