Compiled cordova android app is built succesfully but doesn't start in android < 4.2

This problem is very annoying and happens only with some users, not all the cordova developer seems to present this error.

You'll only receive this "magic" information :

BUILD SUCCESSFUL

Total time: 3.43 secs
Built the following apk(s):
    C:\android\myproject-hello\platforms\android\build\outputs\apk\android-debug.apk
Installing app on emulator...
Using apk: C:\android\myproject-hello\platforms\android\build\outputs\apk\android-debug.apk
Launching application...
LAUNCH SUCCESS

That can make you crazy ! Fortunately the solution is really simple.

We will edit 2 javascript files, the emulator and device files which are the cause of the problem. If you are testing on emulator, you can edit only the emulator file and if you are using a device then edit only the device file, but if you want , you can edit both of them for future ocations.

Locate :

// edit this if you test your app with a device
platforms\android\cordova\lib\device.js

// Edit this if you test your app with emulator
platforms\android\cordova\lib\emulator.js

Then search this line : 

(on device.js is near at the line 102 and on emulator.js is near at the line 313)

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

And replace with :

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

You only need to remove the "-d" option, then the app will run normally with cordova run android.

Become a more social person