Flutter - run/debug desktop app directly from Android Studio [configuration] - android-studio

I want to conveniently develop Desktop applications using Flutter & Android Studio. Currently Flutter Desktop Apps run only on the master channel.
I'm able to flawlessly enable MacOS as a flutter device with export ENABLE_FLUTTER_DESKTOP=true where my macos laptop shows as the following device:
$ flutter devices
1 connected device:
macOS • macOS • darwin-x64 • Mac OS X 10.14.5 18F132
I can launch the app directly on desktop with flutter run
Which Run/Debug configuration should I choose to automatically build & launch Flutter app from Android Studio?
Flutter ver. Channel master, v1.9.8-pre.108
EDIT: as #smorgan correctly suggested, just run:
flutter config --enable-macos-desktop
Remember that you also need to have macos build target in your app workspace:

You should not use ENABLE_FLUTTER_DESKTOP; any instructions referencing it are out of date. You should instead run flutter config --enable-macos-desktop as described in the official documentation.
That approach will enable desktop support everywhere, including Android Studio, rather than just the current terminal. Once you do that, normal Flutter workflows in Android Studio will work for desktop.

Related

How to run an app on an iPhone simlator with Android Studio on mac?

I want to get started with flutter. I have downloaded flutter and the Android Studio and XCode. In Android Studio, I can select the ios simulator from the drop down menu, but all that does is turn the simulator on and doesn't actually run my app. I am not sure what else do I have to do?
Open your app on Xcode, xcode will configure somethings. When you compile from android studio to an iphone emulator, xcode compiles the project, so it needs to configure the project at least once. You may need to go to the project's ios folder and run pod install to install the ios dependencies.

Exception: No Linux desktop project configured error on flutter project

When I try to build my app to Flutter Desktop its fail with this message:
Running "flutter pub get" in project...
Launching lib/main.dart on Linux in debug mode...
Exception: No Linux desktop project configured. See https://github.com/flutter/flutter/wiki/Desktop-shells#create to learn about adding Linux support to a project.
My configuration is:
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.20.0-3.0.pre.126, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 4.0)
[✓] Connected device (3 available)
• No issues found!
you have to manually add desktop support for existing apps
run: flutter create .
to add the necessary dependencies.
To add desktop support to an existing Flutter project, run the following command in a terminal from the root project directory:
flutter create --platforms=windows,macos,linux .
src : https://flutter.dev/desktop#add-desktop-support-to-an-existing-flutter-app
You might have missed step from linux desktop support. It is because you're trying to run project which is initial build from different platform (eg. mac/windows). This is according to official documentation.
flutter_add_linux
Another solution is create new app by flutter create repo_name on linux. Then copy linux folder into existing repo. This will fix your problem.
While run desktop app error
solution:
To add desktop support to an existing Flutter project, run the following command in a terminal from the root project directory:
Here we add full desktop support
flutter create --platforms=windows,macos,linux .
Only need Windows
flutter create --platforms=windows .
Only need Linux
flutter create --platforms=linux .
Tip:
To create a new application that includes desktop support (in addition to mobile and web support), run the following commands, substituting myapp with the name of your project:
flutter create myapp
cd myapp
For more Information : flutter.dev/desktop
Use these commands
$ flutter channel dev
$ flutter upgrade
$ flutter config --enable-linux-desktop
After running these commands start a new Flutter project and you should be good to go. :)

Problems with setting up Android Studio with Flutter on Mac

I made my project on Windows computer, now I'm trying to export to ios on friend's Mac. I've been following this tutorial from part 1 all the way to part 5. How to Install and Setup Flutter for App Development on Mac - Part 1. In other words, Xcode is installed, Android Studio with Flutter and dart plugin installed as well. Android Studio recognizes both simulator and plugged iPhone. When I open the project in Android Studio it looks like this:
Note: Both flutter folder and the project folder are located in "exportalex"
Please try to use terminal and hit this: flutter pub get
You need to load all the dependency before run app.
If still you are facing same issue, please run: flutter doctor
Then share screenshot of result.

<Flutter> emulator launched but not detected by android studio

I'm a beginner in Flutter and I've an emulator opened/powered on and android studio doesn't detect it.
Hence I can't run any program because "no device is running". I've tried installing 'Android emulator' in the SDK tools but android studio still cant detect it.
Android Studio device list shows "loading" and no devices connected. Thus, I opened emulator but I cannot run flutter on emulator on Android Studio. After 5 hours I found that the reason is the new Flutter version.
I solved with choose different version of Dart and Flutter!
You need to download 1.17.3 version. Quick download link: Dowloand Flutter SDK 1.17.3 Version
And switch Stable Channel & Dart: 2.8.4, this is important. Also, if you want, you can check all versions of Flutter SDK: Flutter Versions
On MacOS, just write terminal: flutter channel stable
Note: If this answer is not working for you, you can open android module of your flutter app in Android Studio. It can be helpful when you try to add Firebase skills.
I had same problem.
CMD: flutter devices
No devices detected.
CMD: device emulators
Device emulator-5554 is offline.
In Android virtual device manager, I cold boot emulator and it started working.
In a windows platform I did:
If you have ran flutter doctor and there is no issues and if you can run your flutter app in cmd or using VSCode:
Just try to open Android Studio or IntelliJ as administrator by right clicking on the icon. This may list down devices and solve your problem.
The reason may be you have cloned flutter repository or you don't have right permission in flutter installed directory.
Run flutter doctor command to check whats the problem.
In terminal, run the flutter devices command to verify that Flutter recognizes your connected Android device.
Check your flutter plugin whether it is up to date.
And read this flutter run: No connected devices , You may find the solution.
For me (on a Mac) I had the Android SDK installed in a custom location so I needed to set the ANDROID_HOME environment variable. In the terminal you can check what this value is with:
echo $ANDROID_HOME
I added the Android SDK to my .bash_profile (might be a different file if you are using Linux or Windows) for both ANDROID_HOME and PATH.
# already had these
export PATH="$PATH":"/opt/android-sdk/tools"
export PATH="$PATH":"/opt/flutter-sdk/bin"
# added this
export ANDROID_HOME="/opt/android-sdk"
Replace /opt/android-sdk with wherever yours is.
Then I updated the variables with
source .bash_profile
Testing with flutter doctor showed it was working.
flutter doctor
I restarted Android Studio and the emulator worked.
The last version of Flutter 1.17.5 (release the 2th, July) solved this issue for me.
Just flutter upgrade
run Flutter doctor to make sure you install everything.
run Flutter devices to see whether it is detected by flutter or not.
if you can find the your emulator there run flutter run -d <YOUR_EMULATOR_ID>
if you unable to find your emulator there may be you have to accept the android licenses . run flutter doctor --android-licenses to accept.
run flutter emulators to see list of emulators you have.
run flutter emulators --launch <emulator id> to launch
run Flutter devices to check whether emulator is detected by flutter or not.
run flutter run -d <YOUR_DEVICE_ID>
What worked for me is, updating Android Emulator.
Visit SDK Manager
Check whether any updates available for Android Emulator
If available, install the newest version
Hope this would be helpful!!!
I had this issue on Android Studio.
I had an emulator but it was not recognized even though the emulator was open.
I got around this by launching developer mode inside of the actual emulator by following the steps in this link: https://tweaklibrary.com/how-to-enable-developer-mode-on-android/#:~:text=How%20to%20Enable%20Developer%20Options%20On%20Android.%201,one%20of%20the%20most%20powerful%20...%20More%20items
After setting the emulator to developer mode, the emulator phone appeared as an option and when I ran the flutter hello world it appeared on the emulator.

Why is Android Studio not finding the x86 emulator when running a flutter app?

Software
MacOS Sierra 10.12.6
Android Studio 3.1.2
Flutter 0.3.2 • channel beta
Tools • Dart 2.0.0-dev.48.0.flutter-fe606f890b
Flutter doctor (no problems found)
Problem
I am using Android Studio IDE to develop flutter apps, but I can't get any of the Android virtual device emulators to launch from the IDE. Whenever an Android virtual device is selected, such as the Pixel P, an error message appears saying "PANIC: the emulator program for the x86 CPU is missing". However, the emulator does work when it is launched from the command line:
$ cd /Users/$USER/Library/Android/sdk/emulator
$ emulator -avd Pixel_API_P
The problem seems to be specific to flutter projects, given that the same virtual devices are being launched normally with Android projects.
I changed the virtual device's x86 image to x86_64 and the problem was solved. Still don't undertand the underlying cause, but it worked:
ADV Manager > edit device > (name_of_device) Change... > x86 images > download & select x86_64 image
Check if your GPU rendering is activated in your BIOS settings.
Generally the BIOS keeps the GPU rendering off. You can change it, then clean your Android Studio, then reload your ADB.
Hope this helps. :)

Resources