Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot run cordova application on device or emulators error running

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.

like image 969
Bhavya Shukla Avatar asked Nov 10 '22 20:11

Bhavya Shukla


1 Answers

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.

like image 185
Serg Tomcat Avatar answered Nov 14 '22 21:11

Serg Tomcat