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

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.

Related

cannot open Andoid emulator on VS Code

I am using the github.com/DiemasMichiels/emulator extension for VS Code. Whenever I try to open the emulator, I get these notifications. what is the problem and what should I do about it?
Something went wrong fetching you Android emulators! Make sure your path is correct. Try running this command in your terminal: "false\emulator" -list-avds
source: Android iOS emulator (extension)
Error: spawn C:\WINDOWS\system32\cmd.exe ENOENT
source: Android iOS emulator (extension)
Make sure your Windows path is set correctly! Example: C:\Users\Me\AppData\Local\Android\Sdk\emulator
source: Android iOS emulator (extension)
If you are using Windows remove .exe from the path
New path should be: :\Users\HUNG\AppData\Local\Android\Sdk\emulator
See this GitHub issue ticket in the DiemasMichiels/emulator extension's repo: Something went wrong fetching you Android emulators #14
Quoting from some of the comments in the discussion thread there:
https://github.com/DiemasMichiels/emulator/issues/14#issuecomment-464050318 :
This is related to my update with #13. Point it to the directory instead of the actual executable file instead and I think it should work just fine! - antonholmberg
https://github.com/DiemasMichiels/emulator/issues/14#issuecomment-464254880 :
In previous version (0.0.7) it works with:
"emulator.emulatorPath": "%ANDROID_HOME%/emulator/emulator.exe"
But now (1.0.0): Only works when i use absolute path like:
"emulator.emulatorPath": "C:\Users\RodrigoSaka\AppData\Local\Android\Sdk\emulator" - RodrigoSaka
Given those comments, you should update your settings.json with something like this, where you give the absolute path to the directory containing the emulator executable instead of the path to the executable:
"emulator.emulatorPath": "C:\\Users\\{username}\\AppData\\Local\\Android\\Sdk\\emulator"

There was a path error when Ubuntu created AVD via avdmanager

I used the command line tools provided by Android to download the SDK tools.Use the command avdmanager create avd -n nexus5_23 -k "system-images;android-23;google_apis;x86_64" --device "Nexus 5" to create the emulator, I found that the mirror path in the file config.ini was image.sysdir.1=sdk/system-images/android-23/google_apis/x86_64/.
Compared with the emulator path created by Win10, the emulator can be started normally after changing it to image.sysdir.1=system-images/android-23/google_apis/x86_64/.
I can't find a solution to this problem in Google.Can you give me some Suggestions? thank you.
The environment:
Ubuntu 16.04 Server
bash.rc
...
export REPO_OS_OVERRIDE=linux
# ANDROID SDK
export ANDROID_HOME=/home/yaorc/android/sdk
export ANDROID_SDK_ROOT=/home/yaorc/android/sdk
export PATH=$PATH:${ANDROID_HOME}/emulator
export PATH=$PATH:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin
export PATH=$PATH:${ANDROID_HOME}/platform-tools
export PATH=$PATH:${ANDROID_HOME}/build-tools/29.0.3
export PATH=$PATH:${ANDROID_HOME}/platforms/android-29
I found the answer after several attempts.
Because my command-line tools are in the SDK root,This causes the system image path to be confused when the avdmanager creates the AVD.
Solution:
I created the cmdline directory in the SDK root, cut the tools folder into the cmdline, and modified the environment variable file to properly create and start avd.

Issue in setting up the Android emulator with React native

I am fairly new to React native and trying to set up Android environment with Visual studio. All the installation has been fairly successful, however, when I try to run the sample app on the android emulator executing the npx react-native run-android command it shows below error -
'C:\Users\Home' is not recognized as an internal or external command,
operable program or batch file.
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:43)
at org.codehaus.groovy.reflection.GroovyClassValueFactory.<clinit>(GroovyClassValueFactory.java:35)
at org.codehaus.groovy.reflection.ClassInfo.<clinit>(ClassInfo.java:109)
However, when i execute adb devices on visual studio, it shows the list of emulator connected -
List of devices attached
emulator-5554 device
What could be the possible reason? Is this because my users name is Home PC? (Is this because there is a space in between) and it is not able to get the correct path?
This is because your java version is updated to the latest version and gradle is not supported with the installed version. what you can do is update the gradle as well
So go to gradle/wrapper folder inside the android folder
Edit gradle-wrapper.properties file and replace distributionUrl
with following value
https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
I too faced the same issue.The problem is with the JDK. From JDK 14 i downgraded to JDK 11(LTS) version. And it worked.
Hope it helps.
Install Java 8 version, which is available Java 8 download
Gradle is not keeping up with the Java Latest versions, so roll back
to previous versions

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

Ionic emulate Ios fails to run The session does not open my app

Ionic emulate ios failed on Mac OS Yosemite. Their have some cases were the ios device emulated, but shortly after the terminal console shoots up the error message below.
** BUILD SUCCEEDED **
No target specified for emulator. Deploying to iPhone-6 simulator
An error was encountered processing the command (code=146):
Invalid device state
An error was encountered processing the command (code=146):
Exception encountered connecting to CoreSimulatorBridge: Unable to connect to CoreSimulatorBridge
ENOENT, no such file or directory '/Users/yay/Library/Logs/CoreSimulator/2CAA2C39-7F22-4AF2-BBDE-86609188F37C/system.log'
Error code 1 for command: ios-sim with args: launch,/Users/yay/code/myApp/platforms/ios/build/emulator/myApp.app,--devicetypeid,com.apple.CoreSimulator.SimDeviceType.iPhone-6,--stderr,/Users/yay/code/myApp/platforms/ios/cordova/console.log,--stdout,/Users/yay/code/myApp/platforms/ios/cordova/console.log,--exit
Error: /Users/yay/code/myApp/platforms/ios/cordova/run: Command failed with exit code 2
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
The issue is because you used sudo to create and/or build the project.
Just input these commands (without the $ of course):
1) Remove with sudo
$ sudo ionic platform remove ios
2) Add iOS back without sudo
$ ionic platform add ios
3) Run iOS emulator
$ ionic emulate ios
Source: https://github.com/driftyco/ionic/issues/4052 (rajkotecha's comment)
Do NOT use sudo when creating or building the project.
Please see https://github.com/driftyco/ionic/issues/4052
I've encountered this issue before, and I believe you messed up with your permission. However, I managed to solve it by reinstall everything from scratch (NOT reformat OS). I suggest you may try to remove all your Xcode, ionic, cordova, and ios-sim content and reinstall again.
Delete your Xcode from your Mac OS.
Remove everything inside:
/usr/local/bin
/usr/local/include
/usr/local/lib/dtrace
/usr/local/share/man/man1
/usr/local/share/systemtap/tapset/
Delete the folder:
/usr/local/lib/node_modules
Once you done the instruction above, kindly use your spotlight to search for keywords such as node, cordova, ionic, etc... to see whether it is still exist or not. Please also ensure yourApp within your Users/username folder is deleted.
You may also try to use your terminal input:
npm -v
cordova -v
ionic -v
It will shows nothing/not found if you've deleted everything completely.
Now you can download and install Xcode from App Store, and wait for Xcode is fully installed in your Mac, then proceed to here to start again your ionic project.
Lastly, once you begin to create an ionic project, by right you no need to use any sudo commands anymore in creating or building this project.
Example:
ionic build ios
Instead of:
sudo ionic build ios
It should be working unless you are not the root user.
Happy coding and have a nice day! :D