3

Good day! I've been reading a tutorial for cordova (https://ccoenraets.github.io/cordova-tutorial/) but when I get to the part where I have to run the app via USB in my cellphone there's a problem.

The console says the launch was successful and there are no errors whatsoever but the only thing that happens in my phone is that it "presses" the menu button, as if it recognizes the app as a "press the menu button", my cellphone is a Samsung Galaxy 5 (I5500).

Some background:

Had to install some packages in the Android Manager, all of them up to date, to run the app in such an old device.

I haven't made any change to the files

AtanuCSE
  • 8,832
  • 14
  • 74
  • 112

4 Answers4

4

I had exactly the same problem and solved it as follows:

From this answer and this answer:

Problem seemed to occur when installing the apk. 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.

Note: You have to use backslashes (e.g., platforms\android\cordova\lib\device.js) on some systems.

Community
  • 1
  • 1
Michal Skop
  • 1,349
  • 1
  • 15
  • 23
1

Cordova 6.5.0 ( same issue ; LAUNCH SUCCESS message / app not launched )

(The install -d option mentioned in previous answers allows installing a version downgrade (http://adbshell.com/commands/adb-install) - it shouldn't affect launching an app. In any case it doesn't appear to be in the 6.5.0 cli code.)

In my case the problem arose following edits to AndroidManifest.xml which otherwise didn't cause a problem ( I set <activity android:name to something of the form com.hello.world.MainActivity (as indicated at sample AndroidManifest.xml))

Your case may differ. To diagnose ;

If you run cordova with it's verbose option (-d) eg.

cordova -d run --target=<deviceId> android

..then in the output about 4 lines before "LAUNCH SUCCESS" You will see the line

Running adb shell command "am start....

where it attempts to start (launch) the app and you will likely see why it is not working (The lack of a space between the -n option and the package details doesn't matter).

Lines of interest are ;

<YourAppDir>\platforms\android\cordova\lib\Adb.js line 98 ;

return Adb.shell(target, 'am start -W -a android.intent.action.MAIN -n' + activityName)

And

<YourAppDir>\platforms\android\cordova\lib\device.js line 90;

 var launchName = pkgName + '/.' + manifest.getActivity().getName();

I changed the relevant AndroidManifest.xml entry back to android:name=MainActivity and everything worked again.

Bob
  • 1,589
  • 17
  • 25
1

For me it was a developer option called 'Verify apps over USB' that I had to turn off in order to get the app to run.

EJ Thayer
  • 151
  • 2
  • 3
0

I had the exact same problem on a OnePlus One device.

In my case: Michal Skop's solution to change the file platforms/android/cordova/lib/device.js and platforms/android/cordova/lib/emulator.js "didn't work" since the "-d" wasn't contained in the file.

I tried disabling 'Verify apps over USB', as EJ Thayer said, but this didn't work either.

The solution was: This phone can have multiple users (Never seen a phone that has this functionality) and I actually deployed it for another user (not the one I was logged in with).

Note: No idea how you could specify for which user you want to install the application.