Wednesday 23 September 2015

How to deploy phonegap to android device


When deploying phonegap project to device, my old android device was not recognized (Nexus S, Android os 4.1.2)

I checked Developer Option >> Enable USB Debug, but still adb returned no device.


I get to know that I have to install Google USB Driver to catch my phone.

Then my phone showed up.
Now when I run the following, it doesn't go to emulator any more but goes directly to the phone! It's because my phone is connected with USB cable.

C:\Users\matthew.oh\Dropbox\my-app\hello\platforms\android>phonegap run android

You can run below also. I guess it's samething. Choose a simple one.

C:\Users\matthew.oh\Dropbox\my-app\hello\platforms\android>adb install build/outputs/apk/android-debug.apk

Voila!



The message.html shows nothing because it didn't have WebAPI codes in there yet.

<The below is needed when your dubugging WepAPI URL is different from Live url>

You have to both update WebAPI and phonegap's message.html to deploy properly in my case. This is because my WepAPI URL had cross domain issue.

Copy any source code change from your debugging environment to phongap project folder.
 Make sure that message.html points to the correct URL.

Change WebAPI project to use a correct url and test it compile correctly.



Publish WebAPI project and copy across to live Web API url. You may need to copy across through FTP only the files you changed.

Now, WebAPI is ready to use.
Check if the live url works fine.
Run phone gap again. You don't need to compile again. It seems it builds first and deploy to device.

Voila again!







No comments:

Post a Comment