cannot run cordova application on device or emulators error running

cordova run android device
cordova deploy to android device
cordova run android emulator
cordova list devices
cordova waiting for emulator to start
cordova run android emulator not working
cordova emulator
run cordova app in browser

When I'm trying to run my Cordova application through command line. My build is successful but running on emulator or device it gives me an error on command line

ERROR: Failed to launch application on device: ERROR: Failed to install apk to d evice: Error: Could not find apk architecture: arm build-type: debug ERROR running one or more of the platforms: Error: cmd: Command failed with exit code 8 You may not have the required environment or OS to run this project

I have specified the the minimum sdk version in the AndroidManifest.xml file

 uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" 

on emulator I am running API version 19, android 4.4.2 and on mobile I am running android 4.4.3 with enabled USB debugging on Sony Xperia ultra t2.

With Visual Studio 2017 and Cordova 7+ had the same problem, but came to a different solution. Cordova now makes subfolder in output dir: /platforms/android/build/outputs/apk/debug/android-debug.apk

In cordova's GenericBuilder.js (build.js now only inherit method we're looking for) in findOutputApksHelper script, of course, doesn't add that subdirectory to search mask:

.....
function findOutputApksHelper (dir, build_type, arch) {
    var shellSilent = shell.config.silent;
    shell.config.silent = true;

    var ret = shell.ls(path.join(dir, '*.apk')).filter(function (candidate) {
.........

So I changed it like this:

..........
function findOutputApksHelper (dir, build_type, arch) {
    var shellSilent = shell.config.silent;
    shell.config.silent = true;

    var subAPKMask = build_type + '\\*.apk';

    var ret = shell.ls(path.join(dir, subAPKMask)).filter(function (candidate) {
............

Maybe it will be helpful to someone, cause I spent two hours of life to find that.

CMD stuck on "Waiting for emulator", That will launch your application in the Android emulator Then, open your Android SDK Manager and install intel x86 Emulator Accelerator 5) If it doesn't run it should print an error to the console you need to resolve  The detection option will be selected by default, to disable detection and use the ARM emulators by default every time, select the No detection option. To run your Apache Cordova application on an Android Emulator: in the Visual Studio Standard toolbar, set the release type to Debug, the target OS to Android,

I think this is a bug in cordova (that only appears when using gradle). It seems to be fixed in the current master branch (which you can use with cordova platform add android@master --usegit )

For the old version I workedaround it like this:

There is a file build.js in your cordova/lib/ folder in your project. This file contains a function findOutputApksHelper which checks if the generated apks match a specific filename scheme. By default the generated debug apks are named android-debug-unaligned.apk, however the method excludes all files that contain "-unaligned". I modified the function like this:

function findOutputApksHelper(dir, build_type) {
    var ret = findApks(dir).filter(function(candidate) {
        // Need to choose between release and debug .apk.
        if (build_type === 'debug') {
            console.log("candidate: "+candidate);
            return /-debug/.exec(candidate);
        }
        if (build_type === 'release') {
            return /-release/.exec(candidate) && !/-unaligned/.exec(candidate);
        }
        return true;
    });

    ret = sortFilesByDate(ret);
    console.log("ret " + ret);
    if (ret.length === 0) {
        return ret;
}

    var archSpecific = !!/-x86|-arm/.exec(ret[0]);
    return ret.filter(function(p) {
        return !!/-x86|-arm/.exec(p) == archSpecific;
    });
}

Run Your Apache Cordova App on Android, When running on an Android emulator, Visual Studio attempts to first use a HAXM enabled emulator. If HAXM is not installed, or cannot be used  Description: The command ionic cordova run android --device fails with ERR_NO_DEVICE: No hardware devices found. Not attempting emulator because --device was specified.

Just remove output.json file from debug/release folder. Then try again.

Android Platform Guide - Apache Cordova, Install the Android SDK from developer.android.com/sdk. You may This should correct all the errors in the project. Deploy to Emulator. You can use the cordova utility to run an app in an emulator, or you can run it within the SDK. Either way  dwieeb changed the title ionic cordova run android --device doesn't work `ionic cordova run android --device` with connected device errors: "ERR_NO_DEVICE: No hardware devices found." Jun 11, 2019 This comment has been minimized.

'cordova run android --emulator' command line tool stuck at 'Waiting , You need to install the Android SDK regardless of whether you want to use This should correct all the errors in the project. You can use either the cordova CLI utility or Cordova's Android-centered shell tools to run an app in an emulator. In USB settings, also make sure you are connecting as a Media device. If you are running on a device and the app is already installed, uninstall the app and try again. Verify that the Android SDK can connect to your device or emulator. To do this, take these steps. Start an emulator or connect a device.

'cordova run android' does not deploy the app to emulator · Issue , OS: Windows 10 Cordova: 9.0.0 ADB: Android Debug Bridge version 1.0.40, I'​ve installed cordova and am using it to develop an android app. I'm running into an issue where I cannot start the emulator form the command line. with error code 1: adb -s,emulator-5584,shell,getprop,dev.bootcomplete  Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Howto Install and Run the Android Emulator, Bug Report Problem 'cordova run android' doesn't deploy the app to the emulator Running adb shell command "ps" on target emulator-5554. Cordova Simulate changes the device profile then reloads the Cordova app in the browser. This enables you to quickly iterate through multiple target device models as you work. As you tweak your app's code, live reload automatically updates the web application files in Cordova Simulate behind the scenes. Changes to the app's HTML and JavaScript code triggers a reload of the app in the browser.

Comments
  • I spent two days and still it is not working your solution has no effect
  • Thanks for your reply. Will Try This and let you know soon
  • I tried this and it did not solve my problem, which is similar. The emulator runs but I cannot get cordova to launch the app on emulator: "Failed to launch app on emulator: Error: Could not find apk architecture: x86 build-type: debug"
  • The methos is now called module.exports.findBestApkForArchitecture