I tried to develop app using Flutter(using Android studio IDE).Add flutter plugin & flutter SDK in studio and Everything is configured but emulator / real time device are not listed. Its shows error like "Unable to list devices: Unable to discover Android devices. Please run "flutter doctor" to diagnose potential issues"
Ref link : https://flutter.io/setup-windows/#android-setup
https://flutter.io/get-started/test-drive/#androidsstudio
configure flutter in terminal to detect Android SDK and Android Studio:
$ flutter config --android-sdk /path/to/android/sdk
$ flutter config --android-studio-dir /path/to/android/studio
then restart Android Studio/Intellij.
source: https://github.com/flutter/flutter-intellij/issues/2113#issuecomment-383412308
If you configure flutter and android sdk both perfectly and you do not show the avd device list in android studio.
It's very simple way to show android emulator device list.
First create a new Android Emulator if already create you run the AVD manager then you can show the instead of emulator name
Before:
https://i.stack.imgur.com/6np0m.png
After:
https://i.stack.imgur.com/fiCYe.png
May be there is no AVD's to list down. And if emulator runnig, intelliJ will grab it.
In Android Studio, you can create a AVD using AVD Manager or using Terminal. Here is how you can do that using Terminal,
First, go to the android sdk installed directory -> tools
and copy the path and in the terminal type cd and paste the path and press enter. Now yo are in the tools directory.
Next, using terminal type:
emulator -list-avds - to list created AVD's(You should be in tools directory to run this command).
If there is a device type emulator -avd <name>. else you can create a one:
type cd bin then,
Use:
avdmanager create avd -n name -k "sdk_id" [-c {path|size}] [-f] [-p path]
As a example:
avdmanager create avd -n Nexus -d 23 -k system-images;android-23;google_apis;x86
Then again go back to tools directory by typing cd .. and type emulator -list-avds. This command will list your created AVD.
To run a AVD type:
emulator -avd <name>
About AVD.
Had the same problem after moving avd's to another disk.
I managed to solve by making ANDROID_HOME system variable to point to the android sdk path.
For mac users,
It was working fine yesterday. In my case I had this in .bash_profile
ANDROID_HOME = Library/Android/sdk
I changed it to,
ANDROID_HOME = /Users/rana.singh/Library/Android/sdk
.bash_profile has
export ANDROID_HOME=/Users/rana.singh/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
It worked.
Related
For our QA team we need to provide an Android emulator without Android Studio.To do this I used the line tools command provided by Google.
I made this folder tree
kit-emulator
-android-sdk
-avd
in the android-sdk subfolder I put the line tools command folder and from this folder using the sdkmanager I download the sdk with this command
sdkmanager --sdk_root=C:\Users\EBERTGU\Desktop\kit-emulator\android-sdk platform-tools emulator platforms;android-30 system-images;android-30;google_apis;x86_64
The download goes smoothly.
The avd folder is designed to accommodate the newly created emulator. For that I use the avdmanager of command line tools with the following command
avdmanager create avd -n "a350" -k "system-images;android-30;google_apis;x86_64" -p "C:\Users\EBERTGU\Desktop\kit-emulator\avd\a350" -f -d "pixel_4_xl"
The emulator is created in the a350 folder contained in the avd folder. You may be wondering what's wrong then. It's s the launch of the emulator.
When I start the emulator with the command emulator #350 I have this error
PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT
Error which is explained by itself. So I set my environment variable ANDROID_SDK_ROOT to C:\Users\EBERTGU\Desktop\kit-emulator\android-sdk
I restart the commande line prompt and start again to start the emulator this time I got this error
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [C:\Users\EBERTGU\Desktop\kit-emulator\android-sdk]!
Now I don't understand why it doesn't work. I searched and opened the emulator ini file inside I found the line
image.sysdir.1=android-sdk\system-images\android-30\google_apis\x86_64\
In despair I changed it to
image.sysdir.1=C:\Users\EBERTGU\Desktop\kit-emulator\android-sdk\system-images\android-30\google_apis\x86_64\
And when I try to start the emulator with the modified image.sysdir.1 line it works !
Anyone have an explanation of why launching doesn't work with base value for image.sysdir.1 and environment variable?
Thank you a lot
Have a nice day
Shindra Guillaume
I found the solution, it was the generation of the emulator from the avdmanager in the bin folder of command tools lines. Just put the files at the root of command tools lines in a subfolder and the system image is properly configured to match that of the root SDK
Prerequisite
Android SDK is well installed (directory : /Users/gamecube/Library/Android/sdk)
How to reproduce :
Run this command : cordova build android
Run this command to launch android emulator : cordova emulate android --verbose
Expected result
The emulator is launched.
Obtained result
Command finished with error code 0: /Users/gamecube/Desktop/geocars/platforms/android/gradlew cdvBuildDebug,-b,/Users/gamecube/Desktop/geocars/platforms/android/build.gradle
Built the following apk(s):
/Users/gamecube/Desktop/geocars/platforms/android/app/build/outputs/apk/debug/app-debug.apk
No scripts found for hook "before_deploy".
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/gamecube/Library/Android/sdk (DEPRECATED)
Running command: adb devices
Command finished with error code 0: adb devices
Could not find either `android` or `avdmanager` on your $PATH! Are you sure the Android SDK is installed and available?
CordovaError: Could not find either `android` or `avdmanager` on your $PATH! Are you sure the Android SDK is installed and available?
at /Users/gamecube/Desktop/geocars/platforms/android/cordova/lib/emulator.js:176:35
at processTicksAndRejections (internal/process/task_queues.js:97:5)
My questions
Why Android Emulator does not work?
and
Why is there this error? :
CordovaError: Could not find either `android` or `avdmanager` on your $PATH! Are you sure the Android SDK is installed and available?
I solved my problem.
How did I do it?
I opened Android Studio, and went to the SDK Manager.
I clicked on the SDK Tools tab, and in the list displayed, I checked: Android SDK Command-line Tools (latest)
I then clicked on Apply (then OK on the pop-up) to download the package in question.
I added the path of avdmanager to PATH in my .bash_profile
I have run source ~ / .bash_profile to refresh
And I launched my command: cordova emulate android --verbose successfully since the emulator has opened well.
Without Android Studio, merely with Android Command Line Tools from Android SDK. Be sure these Android Command Line Tools (such as sdkmanager or avdmanager) are in the PATH, otherwise run them using the full path (for Debian/Ubuntu see this to install Android SDK).
Install the emulador
sdkmanager --install "emulator"
Install the platforms, example for Android API 32 and 33 (Android 12 and 13 respectively):
sdkmanager --install "system-images;android-32;google_apis;x86_64"
sdkmanager --install "system-images;android-33;google_apis;x86_64"
Create the Android Virtual Device (AVD), example:
avdmanager create avd -n emulator32 -k "system-images;android-32;google_apis;x86_64"
Confirm that was installed
avdmanager list avd
Run
cordova emulate android --target=emulator32
I am trying to install and run an Android Virtual Device from the command line on Windows (without Android Studio). I have set up an Android SDK in C:\Android, and successfully created an AVD with the command:
avdmanager create avd -n test -k "system-images;android-26;google_apis_playstore;x86" --abi google_apis_playstore/x86
I have environment variable ANDROID_SDK_ROOT set to C:\Android.
When I try to start the emulator from the command line with:
emulator #test
I get errors:
emulator: ERROR: can't find SDK installation directory
emulator: could not find virtual device named 'test'
I have also tried setting environment variables ANDROID_AVD_HOME and ANDROID_EMULATOR_HOME, and also tried running the AVD specifying sysdir and datadir with the command:
emulator #test -sysdir C:\Android\system-images\android-26\google_apis_playstore\x86 -datadir C:\Android\avd
but I get the same errors.
When I run command avdmanager.bat list avd, I get:
Name: test
Path: C:\Android\avd\test.avd
Target: Google Play (Google Inc.)
Based on: Android API 26 Tag/ABI: google_apis_playstore/x86
Why on earth can't I run the AVD?
I found the problem. Because I was trying to do a minimal Android SDK install via the command line, I did not yet have a platform-tools folder. Not being able to find the platform-tools folder was causing the emulator to display the unhelpful error "can't find SDK installation directory", which really meant "can't find the platform-tools directory".
Once I installed the platform-tools folder with sdkmanager --no_https "platform-tools", the emulator worked. I need --no_https because I'm in a crippled corporate environment.
For future reference, I installed the emulator dependencies (after unzipping sdk-tools-windows-3859397.zip from here) with:
sdkmanager --no_https "system-images;android-26;google_apis_playstore;x86" "platforms;android-26" "platform-tools" "emulator"
With the package "platform-tools", it may also required to install "platforms;android-26" for your Android 26.
Using sdkmanager.bat platforms;android-30 --sdk_root=C:\your_avd_sdk_root to install it.
If still not working, try to run command below:
set PATH=%PATH%;%ANDROID_SDK_ROOT%\emulator
set PATH=%PATH%;%ANDROID_SDK_ROOT%\emulator\bin64
set PATH=%PATH%;%ANDROID_SDK_ROOT%\platform-tools
set PATH=%PATH%;%ANDROID_SDK_ROOT%\cmdline-tools\latest\bin
I'm trying to install just the Android Emulator on my Mac, not the whole Android Studio.
So far I have:
1) Installed Android-SDK via Homebrew
brew cask install android-sdk
2) Added to my $PATH, and checked I have no other ANDROID related PATHS going on.
export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"
3) In terminal running
$ANDROID_SDK_ROOT
shows
/usr/local/share/android-sdk: is a directory
4) Created a new AVD in with AVDManager.
5) Try to run created AVD and get this error
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/usr/local/share/android-sdk]!
I also can't run 'emulator' from the command line, I CAN run avdmanager and sdkmanager fine.
I've checked the path which appears to be correct. The AVD is in the location of
/Users/<user>/.android/avd/test.avd
Where could I be going wrong?
I had the same issue on Linux, trying to build a Docker image for the emulator, and finally find out what the reason was by looking at the Android emulator source code.
I installed only the required SDK packages for emulator ("emulator" and one of the "system-images"), but the emulator program check if ANDROID_HOME or ANDROID_SDK_ROOT path contains the "platforms" and "platform-tools" directory, so I installed the "platform-tools" package and one of the "platforms" package and it worked.
Manually create those two empty directories should also be enough.
I'm using Linux (fedora 16). I try to install Android SDK and ADT. Each time I want to run Android SDK or Android Emulator, I must run from Eclipse, but I don't know how run directly. (don't need to open Eclipse)
In Windows, in AndroidSDK folder has file exe so you can run directly such as AVD Manager.exe or SDK Manager.exe but not in Linux.
Please help me about this issue.
Thanks :)
You can launch android SDK manager by simply moving to android-sdk/tools folder and using the following command:
./android &
To launch the emulator, from the same folder you need to execute the following command:
./emulator -avd youravdname
It's better to store Android SDK in /opt/ and just run:
$ sudo /opt/android-sdk-linux/tools/android
You can add & at end to run it as background process.
try using the following commands , this should work if you have installed the sdk correctly
Open a terminal
su
input your password
cd Android/SDK/tools (enter)
./emulator -noaudio #android_dev