Ionic 4: No emulator images (avds) found - javascript

I'm trying to emulate my ionic 4 app into Android Emulator
so I run the command:
sudo ionic cordova emulate android --prod
I get this error:
BUILD SUCCESSFUL in 1s
42 actionable tasks: 42 up-to-date
Built the following apk(s):
/Users/esham/Desktop/magazine-app/platforms/android/app/build/outputs/apk/debug/app-debug.apk
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/esham/Library/Android/sdk (DEPRECATED)
No emulator images (avds) found.
1. Download desired System Image by running: /Users/esham/Library/Android/sdk/tools/android sdk
2. Create an AVD by running: /Users/esham/Library/Android/sdk/tools/android avd
HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver
[ERROR] An error occurred while running subprocess cordova.
cordova emulate android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
But I have 3 ADV on ADV Manager!!
And I could run any one of them by terminal for examble emulator #Pixel_2_API_26
These the list of ADV I have: emulator -list-avds
Pixel_2_API_26
Pixel_2_API_28
Pixel_3_API_28
When I'm running command android list avd getting:
The following Android Virtual Devices could not be loaded:
Name: Pixel_3_API_28
Path: /Users/esham/.android/avd/Pixel_3_API_28.avd
Error: Google pixel_3 no longer exists as a device
---------
Name: Pixel_2_API_26
Path: /Users/esham/.android/avd/Pixel_2_API_26.avd
Error: Google pixel_2 no longer exists as a device
---------
Name: Pixel_2_API_28
Path: /Users/esham/.android/avd/Pixel_2_API_28_1.avd
Error: Google pixel_2 no longer exists as a device
So it doesn't make any sense! I have 3 ADV with all supported levels by cordova and keep saying No emulator images (avds) found.
These my environment setup on macOS:
export ANDROID_SDK=$HOME/Library/Android/sdk
export PATH=$ANDROID_SDK/emulator:$ANDROID_SDK/tools:$PATH
export ANDROID_HOME="$HOME/Library/Android/sdk"
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH/:$ANDROID_HOME/platform-tools

I have solved the issue by adding --emulator=amulator_name
So the full command will be:
ionic cordova emulate android --prod --emulator=Pixel_3_API_28

If you run "ionic cordova run android" it's automatic run emulate by default. so try this. I hope it fixed your issue. firstly you check you Emulated Android path and it is properly downloaded or not. You run "ionic cordova resources" it checks all resources if fine or not. You need to be install anything or not. so try this.

Related

Unable to solve Android target error in Meteor add-platform android

I using a Macbook Pro M1 and decided to do start developing mobile app using Meteorjs framework, since I've used the framework for web development. I've followed a tutorial online on how to get that going but currently facing a problem:
Status of the individual requirements:
✓ Java JDK
✓ Android SDK
✗ Android target: Command failed with exit code 1: avdmanager list target
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.AvdManagerCli.run(AvdManagerCli.java:213)
at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 5 more
✓ Gradle
It seems that there's only one requirement that failed, and I've searched for the solution but couldn't find anything that resembles a similar problem that I'm facing. Hoping for you to help point me to the right direction.
I have installed the Android Studio, uninstalled and reinstalled the Android SDK Build-Tools 32, Android SDK Command-line Tools, Android SDK Platform-Tools, and Android Emulator.
Currently, my ~/.bashrc file setup is like this:
export ANDROID_HOME=$HOME/Android/Sdk
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
...and my ~/.bash_profile:
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
export CLASS_PATH=$JAVA_HOME/lib
and I've got Gradle working just fine. Tested building a generic Android app using one of the samples in Android Studio. The build was successful.
But I can't get the meteor add-platform android to pass the checks. Anyone?
This problem was solved by installing JDK8.
Source for Macbook Pro M1: https://www.azul.com/downloads/?version=java-8-lts&os=macos&architecture=arm-64-bit&package=jdk

An error occurred while running subprocess cordova. Why?

I make mobile game on JS, and i use Ionic for build Android app.
For adding to my project Android Platform i writed:
C:\TB>ionic cordova prepare android
But this back me:
? Platform android is not installed! Would you like to install it? Yes
> cordova.cmd platform add android --save
You have been opted out of telemetry. To change this, run: cordova telemetry on.
Using cordova-fetch for cordova-android#9.1.0
Adding android project...
Could not load API for android project C:\TB\node_modules\cordova-android
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd platform add android --save exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
At my node_modules folder have subfolder cordova-android, why ionic?!
How can i fix this?
P.S. My android SDK at needed folder AppData\Local\Android\Sdk
Try running the following commands
ionic cordova platform rm android
ionic cordova platform add android
ionic cordova build android

React Native, why react-native run-android not working?

I'm trying to run react native run-android after I update my project file, but whenever I run react-native it throws an error. When I created that project and that command it worked fine but when I edit and add some files like apps/redux, apps/components, screens etc it stopped working. Can anyone tell me why it's not working?
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
> Task :app:compileDebugJavaWithJavac
> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
> Task :app:installDebug FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
27 actionable tasks: 6 executed, 21 up-to-date
Note: C:\Users\Danger World\ReactProject\android\app\src\debug\java\com\reactproject\ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 11s
error Failed to install the app. Make sure you have an Android emulator running or a device connected. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: C:\Users\Danger World\ReactProject\android\app\src\debug\java\com\reactproject\ReactNativeFlipper.java uses or overrides a deprecated API.
you either need to create a virtual device or connect a physical device with USB debuging enabled (https://developer.android.com/studio/debug/dev-options).
To create a virtual device, open android studio and select AVD manager from Configure menu and create a new virtual device downloading required packages.
In case you are using a virtual device with Android studio then try to manually run the emulator BEFORE react-native run-android.
(open android studio > Tools > AVD Manager > Create Virtual Device)
https://developer.android.com/studio/run/managing-avds#createavd
Or repeat the official installation guide:
https://reactnative.dev/docs/environment-setup

ionic 2 - Application error DEVICE_READY_TIMEOUT

My Ionic 2 running on Opensuse Linux. The app runs and builds fine, However I am not able to change DEVICE_READY_TIMEOUT as it is set to 2000ms
I tried changing the value of DEVICE_READY_TIMEOUT in main.js, but that file is regenerated every time I run ionic build or run. Could anyone help ?
At the moment it throws an Application Error, on debugging in browser it says
main.js:25553 Native: device ready did not fire within 2000ms. This
can happen when plugins are in an inconsistent state. Try removing
plugins from plugins/ and reinstalling them. (anonymous) #
main.js:25553 main.js:25548 DEVICE READY FIRED AFTER 19860 ms
I have tried reinstalling a number of times, its the same. I am able to work with the app through chrome debugging. But on the android phone it shows an Application Error Dialog box.
The issue surfaced only after adding the angularfire2 library for firebase database.
System Info
Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 0.0.48
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.1
Node Version: v6.9.0
Xcode version: Not installed
OK Finally found out, the issue started when I was forced to remove the plugins and reinstall them due to the bugs in the current ionic 2 Rc3 framework. I ended up not reinstalling the device plugin as it wasn't saved in the package.json file nor in the config.xml.
so the solution was to simply add the device plugin
ionic add cordova-device-plugin --save
Don't forget to add the --save option, as this adds it to your config file, and is useful should you need to reinstall the platform & plugins over again.
The other part of the problem - TIMEOUT_ERRORS can be solved by adding a line to the config.xml , if your device is taking longer to load up during the startup.
<preference name="loadUrlTimeoutValue" value="400000"/>
The timeout value is in milliseconds. as my app was taking around 30 seconds to load, I have set the timeout value to 40 secs.
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-device/

Ionic run android not working

After pulling from the git repo after some time and few changes done by my colleagues, running app on my android device stopped working. I was able to run my app on my device before with usb debugging enabled, but now I get the following error after running the command ionic run android:
No target specified, deploying to emulator Error: No emulator images
(avds) found.
1. Download desired System Image by running: /Users/myUser/Library/Android/sdk/tools/android sdk
2. Create an AVD by running: /Users/myUser/Library/Android/sdk/tools/android avd HINT: For a
faster emulator, use an Intel System Image and install the HAXM device
driver
Go to the Android Studio open the AVD Manager then create AVD(if not yet created) and launch it in the emulator. Now execute the command ionic run android it will run correctly.
Possible duplicate of adb not finding my device / phone (MacOS X)
I had the same problem and can resolve this by restart my device and my Mac.

Categories