How to remove a flutter emulator - flutter

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]

Related

flutter stuck on Compiling, linking and signing

Flutter project is stuck in Compiling, linking and signing... i dont just understand why this is stuck here...
even using verbose i dont get any stack trace on why this is stuck...
Launching lib/main.dart on iPhone 13 Pro Max in debug mode...
Running pod install... 11.6s
Running Xcode build...
└─Compiling, linking and signing...
The problem should be in the existing project created on previous environment (old versions) and has to be resolved by creating a new one and moving content in.
Move all my custom contents from existing my project (assets, fonts, lib folders and config files...) to this new project and ran the command : the flutter build ios command works well now !
following this : Fixing Xcode 9 issue: "iPhone is busy: Preparing debugger support for iPhone"
I TRIED :
On Xcode:
Go to "Window" -> "Devices and Simulators"
"Unpair iPhone" (on the side list, right clic)
Then:
Unplug and plug again the USB cable
Press Trust in the prompt message in the device
in Flutter Terminal, paste and enter :
flutter clean
flutter pub get
cd ios
pod install --repo-update
cd ..
Then run the app.
==> Worked only 1st time for me.
My work around for launching IOS devices for now:
Each time I want IOS device,
I COPY/ PASTE and press ENTER on the Terminal:
flutter clean
flutter pub get
cd ios
pod install --repo-update
cd ..
flutter run

tns run android displays colours instead of actual application

I'm following the tutorial on how to setup the android emulator through https://docs.nativescript.org/angular/tooling/android-virtual-devices.
I ran these commands
Change into the tools bin dir
: cd /usr/local/android/sdk/tools/bin
: sudo chmod +x
Install system images (must be done as root)
: sudo ./sdkmanager "system-images;android-25;google_apis;x86"
: sudo ./sdkmanager --licenses
Say 'y' to all
: sudo touch ~/.android/repositories.cfg
List available Android Virtual Devices to install (done as user)
: ./avdmanager list
: ./avdmanager create avd -n test -k "system-images;android-25;google_apis;x86"
Now I get the following when I list through avdmanager
: ./avdmanager list avd
: Available Android Virtual Devices:
: Name: test
: Path: /root/.android/avd/test.avd
: Target: Google APIs (Google Inc.)
: Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
Now try and run the android emulator
: cd ~/code/MyApp
: tns run android
Once this is started the Android emulator does start up on my Debian 8 thin client but it shows up like the attached image.
Update: Running through Android Studio
It's the same result. I've got this type of result also running the the command line. Funny enough you can actually click buttons when it looks like this and still use it, although it's pretty useless.
Update: Can run through X2go
I ran a test remotely today using the same server and I can run the emulator through the X2go remote login software, but not natively on the thin client. I'm starting to think this is a specific problem of running android emulators under LTSP (thin client).
As I'm running the emulator on a thin client it doesn't look like I can use the 3d hardware acceleration so I've managed to turn it off with the following and the emulator now works pretty good.
$ANDROID_HOME/emulator/emulator -avd test -gpu guest
I'm also using the i3 tiled windows manager and had to force floating on this window;
# Set floating windows
for_window [title="Android Emulator - test:5554"] floating enable

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

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"

Start android emulator without starting Android Studio for flutter applications

Is it possible to start emulator in such a way flutter doctor detects it and flutter run should able to deploy to flutter code ?
I tried emulator -avd *image name* but flutter doctor fails to detect running emulator and flutter run does not deploys code on emulator.
In notepad type the following and save it as "file_name.bat" and run it:
SET builddir=%~dp0
SET EX="C:\Users\user_name\AppData\Local\Android\Sdk\emulator\emulator.exe"
CALL %EX% -avd emu_name -partition-size 512 -feature WindowsHypervisorPlatform
pause
emu_name is the name of your emulator.
first you must change directory of your command line to ${android_SDK_DIR}\emulator
most of the time its in c:\users\${yourUserName}\AppData\Local\Android\SDK\
and run emulator -list-avds and it show you your emulator that you create before in android studio then just run emulator #${your emulator name that shows on the list} for example emulator #Nexus6_API_27
remember that maybe your android sdk folder directory was change on install SDK and if you don't create emulator in android studio before , the list will be empty so before you run command you must create AVD in your android studio
It looks like an adb issue, not of the Flutter doctor issue. Because if adb is running perfectly then it would show you a list of devices from android studio or from flutter devices or by running a adb devices command.
You can try restarting adb using commands:
adb kill-server and
then adb start-server
I think the easiest method I found is you just go to cmd
flutter emulator -- launch <emulator id
it will run and will be detected by your intelli j
I have to get an answer in here somehow, even if it's to offer that the command may also be plural. Yes, indeed, you can run "flutter emulators" from your flutter\bin directory (if you haven't added to system PATH yet) and voila...
PS C:> flutter emulators 1 available emulator:
Pixel_2_API_28 • pixel_2 • Google • Pixel 2 API 28
To run an emulator, run 'flutter emulators --launch '. To
create a new emulator, run 'flutter emulators --create [--name xyz]'.
You can find more information on managing emulators at the links
below: https://developer.android.com/studio/run/managing-avds
https://developer.android.com/studio/command-line/avdmanager

Run react-native on android emulator

I try to run react-native app on genymotion android emulator on my mac.
When I write react-native run-android It gets
Running /usr/local/opt/android-sdk/platform-tools/adb reverse tcp:8081 tcp:8081
error: closed
Could not run adb reverse: Command failed: /usr/local/opt/android-sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && ./gradlew installDebug...
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
MacBook-Pro-MacBook:ART-CarefulPeople macbook$
Then I've tried:
react-native start
react-native run-android
The same result.
Then I've tried:
react-native bundle --entry-file index.android.js --platform android --bundle-output android/app/src/main/assets/index.android.bundle
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
react-native run-android
The same result.
I've tried just adb reverse tcp:8081 tcp:8081 and it says error: closed
When I try to run app on android-sdk emulator it gets the same error above but without error: closed.
From android studio I can run this app and it works on genymotion.
Tell me please what should I do to run my app on android emulator?
I had a similar problem, and after spending so much time and lots of searching about this issue the only trick worked for me:
Please Install the Required SDKs as shown in this figure
Configure Required SDKs
If You have already installed it, so you must have to update the following SDKs:
Android SDK Tool (update it to latest version)
Android SDK Platform-tools (update it to latest version)
Android SDK Build-tools (update it to latest version)
Android Support Repository under Extra folder (update it to latest version)
You Must have at least Installed the Same version Android API as the installed Android SDK Build-tools & Android SDK Platform-tools version as shown in the Configure Required SDKs figure above.
Note: Local Maven repository for Support Libraries which is listed as the SDK requirement in the official docs of React-native is now named as Android Support Repository in the SDK Manager .
On macOs I manage to fix this by adding:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
to ~/.zsh_profile file.
and than type to your terminal
source $HOME/.zsh_profile
The issue was caused by using iTerm2 shell so it's required to edit its own config instead of default $HOME/.bash_profile as described in the official documentation https://reactnative.dev/docs/environment-setup
React Native (On Mac OS Big SUR)
i was stuck here. But updating the environment settings for Android studio did the trick.
nano ~/.zshrc
and paste
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator:$PATH
export PATH=$PATH:$ANDROID_HOME/tools:$PATH
export PATH=$PATH:$ANDROID_HOME/tools/bin:$PATH
export PATH=$PATH:$ANDROID_HOME/platform-tools:$PATH
export JAVA_HOME=$(/usr/libexec/java_home)
control + o to save
then enter
then control + x to exit
then do
source ~/.zshrc to compile
kill the runnig terminals and run
npx react-native run-android
You can also try use "doctor" command. It will fix most cases.
npx #react-native-community/cli doctor
I had similar issue running emulator from android studio everytime, or on a physical device. Instead, you can quickly run android emulator from command line,
android avd
Once the emulator is running, you can check with adb devices if the emulator shows up.
Then you can simply use
react-native run-android to run the app on the emulator.
Make sure you've platform tools installed to be able to use adb. Or you can use
brew install android-platform-tools
It happened to me that I had an instance of the packager running with an old project (I ran react-native start as usual). I was using Ubuntu 14.04. So what I did was to stop that instance and go to my project folder and in two different console tabs I ran these two commands separately:
npm start #here I used to run react-native start
react-native run-android
npm start is defined in my package.json as:
"start": "node_modules/react-native/packager/packager.sh"
I don't know if there is a sort of confusing stuff for react-native but that did the trick.
On Windows 10 and Android Studio you can go in Android Studio to "File"->"Settings" in Settings then to "Appearance & Behavior" -> "System Settings" -> "Android SDK".
In the Tab "SDK Tools" active:
"Android SDK Build-Tools .."
"Android Emulator"
"Android SDK Plattform-Tools"
"Android SDK Tools"
If all installed then you can start the Emulator in Android Studio with "Tools" -> "Android" -> "AVD Manager".
If the Emulator run you can try "react-native run-android"
If emulator not installed then try this command, (if homebrew installed)
brew install android-platform-tools
might be it will help.
Had a similar problem. I updated my Genymotion and my android SDK's/libraries/dependencies and all seemed to work. To update my SDK's I used android sdk manager {ANDROID_SDK_FOLDER}/tools/android sdk
In my case, there was an issue with the android/gradlew file. I think this happens when we move the code from Windows to Mac OS.
Reference:- https://stackoverflow.com/a/62216646/4786087
I was able to clean the android/gradlew file by running the following commands -
Step 1. On android folder cmd run
chmod +x gradlew
Step 2. After that run
./gradlew clean
Step 3. Next in the root of the project, run
react-native run-android
This should start building the app and launch it in the simulator if everything else is fine.
Try
brew cask install android-platform-tools
adb reverse tcp:9090 tcp:9090
run the app
In my case, this was happening because the android/gradlew file did not have execute permission. Once granted, this worked fine
You probably haven't run the Android SDK in forever.
So you probably just have to update it.
If you open the Android Studio Software it'll probably let you know that and ask to update it for you. Otherwise refer to following link: Update Android SDK