Flutter: While creating new emulator , it is showing error as No device definitions are available, Why so? - flutter

I am trying to create new emulator but unable to create it in Visual Studio code. It is showing 'No device definitions are available.'

Not sure on which OS you are working, from windows you should be able to create one like this:
cd C:\Users\<Username>\AppData\Local\Android\Sdk\tools\bin
avdmanager create avd -n "FlutterEmulator" -k "system-images;android-27;google_apis;x86" -d "Nexus 5"
In case the image is not available, it's possible to download it with:
sdkmanager "system-images;android-27;google_apis;x86"

Related

How to add mac os support to a flutter package project?

I have tried running the terminal command:
flutter config --enable-macos-desktop
but it gives me error:
The "--platforms" argument is not supported in package template
for an existing project just run
flutter create --platforms=macos .
See also here some official docs from the flutter website:
https://docs.flutter.dev/development/platform-integration/desktop#add-desktop-support-to-an-existing-flutter-app
I have found work around:
copy mac os folder from a new natural flutter project(non-package):
open terminal & run:
cd example/macos
3.run:
pod install
then
flutter run

Flutter macOS app: Unable to find executable to run

I have an app that runs perfectly on the iPhone simulator and Chrome. However, when I try to run it as native macOS app, it fails with the below error dump. I tried running flutter clean but no luck. Can anyone please help me with it? Do let me know if I can share any files that can help debug this issue.
% flutter run -d macos
Launching lib/main.dart on macOS in debug mode...
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:x86_64, id:XYZ-ABC }
{ platform:macOS, name:Any Mac }
Building macOS application...
Unable to find app name. /location/myApp/macos/Flutter/ephemeral/.app_file
name does not exist
Unable to find executable to run
Error launching application on macOS.
Try recreating your macos directory. For example, by running the following bash script from your top-level Flutter project directory.
# Archive macos directory just in-case you want to undo later
mv macos ~/Desktop/
# Recreate macos directory from scratch
flutter create --platforms=macos .
# Try again to run the app on macos
flutter run -d macos

Error: ADB exited with exit code 1 - remedy?

I am trying to debug a demo app of flutter in vscode where the error is showing for ADB exit with code 1
performing streamed install. I uninstall the existing Flutter demo app.
You should try with these three stuff:
Check out if your emulator memory full.
Check your package name is alright
Clean your flutter and re-run
flutter clean
flutter run
as APK built is Successful there is no issue with the code.
there is something wrong with the device
check u enabled USB debugging
check u enabled install over USB in developer option
few devices don't have to enable install over USB.
then
flutter clean && flutter pub get
uninstall the app in the device and run
flutter run -d <device name>
emphasized text

How to remove a flutter emulator

Running flutter emulators --create --name apple_ios_simulator will create a duplicate emulator named apple_ios_simulator but set the device type to a Pixel by default. Now if you run flutter emulators --launch apple_ios_simulator a Google Pixel emulator is launched.
Is there CRUD options for individual flutter emulators or a way to revert to the default set of emulators?
Using Android Virtual Device Manager to delete Android emulators
Open the Android Studio, click on Tools -> ADV Manager.
A new screen will open with a list of your Android emulators, just click on the arrow in "Action" column and then "delete".
I know is not a complete answer but i hope it can help you to delete at least the Android emulators from your flutter emulators list.
In android use
Run emulator:
emulador -avd [NAME DEVICE]
List emulator
avdmanager -v list
Delate emulator
avdmanager -v delete avd -n [NAME EMULATOR]
Solution:
avdmanager list avd
avdmanager delete avd -n flutter_emulator
How did I found this?
android → depricated
avdmanager -h → show help
avdmanager delete -h → show help
Valid actions are composed of a verb and an optional direct object:
- list : Lists existing targets or virtual devices.
- list avd : Lists existing Android Virtual Devices.
- list target : Lists existing targets.
- list device : Lists existing devices.
- create avd : Creates a new Android Virtual Device.
- move avd : Moves or renames an Android Virtual Device.
- delete avd : Deletes an Android Virtual Device.
Action "delete avd":
Deletes an Android Virtual Device.
Options:
-n --name : Name of the AVD to delete. [required]

"ERROR : No emulator images (avds) found" running ionic on osx 10.10

This is the full error message I got after running ionic emulate android
*running cordova emulate android
Running command: /Users/DeadLift/Documents/ionic/myApp/hooks/after_prepare/010_add_platform_class.js /Users/DeadLift/Documents/ionic/myApp
add to body class: platform-android
Running command: /Users/DeadLift/Documents/ionic/myApp/platforms/android/cordova/run --emulator
ANDROID_HOME=/usr/local/Cellar/android-sdk/24.1.2
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
/Users/DeadLift/Documents/ionic/myApp/platforms/android/cordova /node_modules/q/q.js:126
throw e;
^
ERROR : No emulator images (avds) found.
1. Download desired System Image by running: /usr/local/Cellar/android-sdk/24.1.2/bin/android sdk
2. Create an AVD by running: /usr/local/Cellar/android-sdk/24.1.2/bin/android avd
HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver
Error: /Users/DeadLift/Documents/ionic/myApp/platforms/android/cordova/run: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23) *emphasized text*
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)*
I follow all the above by creating an avd and it give me the same message again.
Thanks.
Vikas's answer is pretty spot on, however (sometimes) just running android avd won't work, which is what I found out after hours of trying to get it working.
When ever I ran android avd in my terminal it would give me the following error:
zsh: command not found: android
This is because I needed to add the Android SDK paths for the platform-tools and tools to my zshrc file (you might be running bash or something else on your terminal).
Simple fix was to add these files to my zshrc PATH environment, You can do this too by using your favourite text editor and depending on what shell you're using.
This link: http://docs.phonegap.com/en/2.8.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android helped me out a hell of a lot getting this fixed.
So I used subl ~/.zshrc (because sublime is my text editor and i've setup symlinks)
I Found my exports PATH and changed it to represent the following:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/dev/.rbenv/versions/2.2.3/bin/ruby:/Users/dev/Library/Android/sdk/platform-tools:/Users/dev/Library/Android/sdk/tools:$PATH"
I then saved the file, closed down sublime and ran source ~/.zshrc in my terminal window, and now I can run android avd and it now opens the Android Virtual Device Manager with no problems.
A reminder your shell might be different to mine (i.e. not running with zsh)and your exports PATH might look different as well, but it's pretty easy to figure out, and the link above will also help if you get stuck.
Actually it is not able to find AVD (Android virtual device). You have to create one.
Type "android avd" from Command Promt to use the graphical manager to setup an emulator image to work with for running your app on. The graphical tool is fairly straight forward to use.