Cordova "hello world" app won't display

Solution 1:

I finally got it figured.

Problem seemed to be that the apk was not properly installed. The application was in fact able to run when i installed it with the following command (as recommanded by jojo in cordova run android executes fine. But Android 4.1.2 doesn't start the app): adb install <path_to_apk>

So I checked Cordova code to see what happens when apk is installed, and manually launched the command Cordova is using:

adb -s ' + resolvedTarget.target + ' install -r -d "' + apk_path + '"

It returns: "Error: unknown option -d"!

If you simply delete the "-d" option, applications run normally with cordova run android. On Cordova 5.0.0 you will find this commande at line 101 of file platforms\android\cordova\lib\device.js (and at line 311 of platforms\android\cordova\lib\emulator.js for cordova emulate android).

I don't know what this "-d" option is meant too... Is this a Cordova bug?

EDIT

As joris says in comment :

The -d is supposed to come directly after adb (as in --device) instead of after install. So you can just move it there instead of removing it.

Plus, here is the opened issue on apache cordova issue tracker

Solution 2:

Goto Platforms > android > cordova > lib > Here you will find device.js and emulator.js

emulator.js

In emulator.js you must change the following line (311) from ->

return exec('adb -s -d' + resolvedTarget.target + ' install -r -d "' + apk_path + '"', os.tmpdir())

To return exec('adb -d -s ' + resolvedTarget.target + ' install -r "' + apk_path + '"')

device.js

In device.js you must change the following line (101) from ->

var cmd = 'adb -s ' + resolvedTarget.target + ' install -r -d "' + apk_path + '"';

To var cmd = 'adb -d -s ' + resolvedTarget.target + ' install -r "' + apk_path + '"';

Once you have changed these rebuild the application and run it on your emulator!