Trying to emulate Android app with cordova, but get this error message:
Built the following apk(s): /Users/jnj/cordova/hello/platforms/android/build/outputs/apk/andr
The Mighty Chris is right, that is the problem and he fixed it upstream (thank you Chris!). However just to add to his answer, for people like me who cannot update cordova-android to include the patch, the fix is (for cordova-android v6.4.0):
<project_root>/platforms/android/cordova/lib/emulator.js
avd.target = 'Android ' + level.semver + ' (API level ' + api_level + ')';
avd.target = 'Android ' + (level ? level.semver : '') + ' (API level ' + api_level + ')';
Here is the relevant patch.
For me, on a Mac, the following was required to get the sdk running in the emulator:
Open Android Studio (and open your project if it doesn't open at start up)
Select 'Tools -> AVD Manager' to open the device manager tool
Right click on the relevant image (or create one if required first)
Select 'Cold Boot Now' and wait for the emulator to boot up
In a terminal cd to the folder where your platforms
and config.xml
. Where cordova
commands can be run
List available devices with adb devices
(Install it if it says not available) to get a list of running devices, and grab your EMULATOR ID. For me on this occasion it was emulator-5554
.
Run the command cordova run android --target "emulator-5554"
replacing emulator-5554
with your own reference.
I had a similar problem and what I did was to run adb devices
on the terminal to check if my device was prorprly connected or not and I found that my device was not connected properly, I think there was a problem with my USB cable and so I disconnected the cable and connected it again an ran the same command adb devices
, then it showed my device as connected. My problem was solved, I hope it'll help someone else.
I was getting this error because I thought the "emulation" command would start the emulator, but it seems to only use one that is already running. Some helpful commands and checks that are available on Windows 10 once you have Android Studio and cordova installed:
cordova run --list
will show no devices and give the semver error.adb devices -l
should show no devices attached.%ANDROID_SDK_ROOT%\emulator
,
%ANDROID_SDK_ROOT%\platform-tools
, %ANDROID_SDK_ROOT%\tools
emulator -list-avds
to see which emulators are available. If none, then add them via Android Studio.start cmd
because you'll need another command line.emulator -avd 7_WSVGA_Tablet_API_30
(note that underscores replace any spaces in the name)adb devices -l
should now show a device like "emulator-5554"cordova run --list
still gives a semver error. (Maybe this is a bug?)cordova run android
(from your app's project directory) should start your app using the default emulator, or you can specify which one with cordova run android --target emulator-5554
This is a bug in cordova-android's list_images method, it crashes when it encounters an android version on your system that's not in its list: https://github.com/apache/cordova-android/pull/422
You can apply the fix manually in platforms/android/cordova/emulator.js
within your project
This is due using an emulator with an unstable Developer Preview API version.
You probably have a device using API 27 (Android 8.1).
Open your AVD, remove that device and re-run.
It's also useful to use --target <emulator_name>
when launching the emulator if you have more than one.
To get a list of available names to use, call the emulate command with --list