9

I've setup cordova 5.0.0 + android SDK API 22 ( Android 5.1.1 ) on ubuntu 12.04 to develop an app. When I run the command

cordova run --device

it builds without errors the APK and shows

Total time: 3.177 secs Built the following apk(s): /var/www/tmp/test-app/platforms/android/build/outputs/apk/android-release-unsigned.apk Using apk: /var/www/tmp/test-app/platforms/android/build/outputs/apk/android-release-unsigned.apk Installing app on device... Launching application... LAUNCH SUCCESS

which however does NOT actually installs the APK to the device.

I have tried to install the ready built APK file using

adb install -r /var/www/tmp/test-app/platforms/android/build/outputs/apk/android-release-unsigned.apk

and it worked.

I have tried to download the APK from a web-server and install it locally on the device and it also worked, so I assume the APK itself is ok and the device is recognized.

When the APK is already installed on the device the command

cordova run --device

produces the same output in the console plus it starts up the app on the device but does not install the newer version it just built.

my android device is an HTC Desire 500 running Android 4.1.2, while my Android SDK is using API 22 ( Android 5.1.1 ) could that be the problem ?

Final note: I have a setup on separate machine using cordova 4.1.2 setup with Android SDK API 19 and it builds the project well and actually DO install the app.

I would appreciate your input on what might cause this strange behavior.

Cheers

Soulshards
  • 91
  • 1
  • 4
  • Thanks for sharing the method to manually install the apk, it helped me significantly, for some reason cordova's routine doesn't work for a subset of devices (It works for my Galaxy S4 but not my Galaxy W) – Kaan Soral Jul 03 '15 at 20:05

3 Answers3

6

Seems to be a bug in Cordova 5.0.0, I had the same problem and the answer by proprit in this thread solved it for me:

On Cordova 5.0.0, adb commands to install the apk can be found 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):

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

Current command returns to me: "Error: unknown option -d"! If you simply delete the "-d" option, applications run normally with cordova run android.

Community
  • 1
  • 1
Humppakäräjät
  • 1,156
  • 2
  • 13
  • 17
  • Brilliant! Great bit of unpicking to determine where Cordova was going wrong. I'm finding that Cordova uses a lot of automation and things that can be easily fixed are made difficult to fix because error messages are not displayed, ( at least in Cordova Tools for VS2015) – Mesh Aug 10 '15 at 10:33
  • Thanks! Seems the rogue `-d` was still present `emulator.js` in Cordova 5.2.0 (not sure about the latest release). – Dunc Apr 08 '16 at 14:35
2
cordova build

adb push "<<project_path_here>>\platforms\android\build\outputs\apk\android-debug.apk" /sdcard/

adb shell pm install -r /sdcard/android-debug.apk

And then you can find your app in your phone and run it ;D

rmartrenado
  • 1,516
  • 1
  • 18
  • 42
0
cordova emulate android

works for the latest version as of this date.

gyaani_guy
  • 3,191
  • 8
  • 43
  • 51