In my previous post we talked about how to create app in Wearable and Handheld devices and created a simple implementation of sending/syncing data. In this post I'm going to demonstrate how to deploy and test apps in real device. First of all I am using Nexus 9 and LG G Watch as my test devices.
Before we start make sure that USB Driver for Android is installed in your machine. You can verify it by right clicking on the COMPUTER > MANAGE > DEVICE MANAGER > OTHER DEVICES. If the driver isn't in the list then you must download the driver here: http://developer.android.com/sdk/win-usb.html and refer this link for the installation guide: http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver
The next important thing is to enable USB Debugging in your Handheld device. You can enable it under SETTINGS > DEVELOPER OPTIONS > USB DEBUGGING. Once you have the required driver installed and enabled debugging for your device then just plug-in your Handheld device to your PC or laptop. In Visual Studio you should be able to see the connected handheld device as shown in the image below:
Deploying the App to Handheld device
Following are the steps for deploying the app:
- Right click on the main app project and select PROPERTIES > ANDROID OPTIONS.Under Packaging tab uncheck the "Use Fast Deployment (debug mode only)
- Under Packaging tab uncheck the "Use Fast Deployment (debug mode only)”
- Unload the project
- Edit the .CSPROJ file and add this PropertyGroup
5. Save and then load the project.
6. Right click on the main app project and set it as the startup project
7. Build the app
8. And then click run or the play button. This will package and install the app to the device. Just wait for it finish.
Deploying the Wear App
You can follow the same procedure for deploying the wear app just like what we did for the main app. If you want to deploy and debug your app over Bluetooth then here are the extra steps:
- Open the Android Wear companion app in your handheld device
- Tap the menu on the top right and select SETTINGS
- Enable "Debugging Over Bluetooth. You should be able to see the status like this:
- Connect the handheld to your PC or laptop over USB.
- In Visual Studio, go to TOOLS > ANDROID > ANDROID ADB COMMAND PROMPT and run the following commands:
adb forward tcp:4444 localabstract:/adb-hub
adb connect localhost:4444
- After that you should be able to see the wear device in device list as shown in the image below:
- Repeat the same steps 1-5 mentioned in Deploying App to Handheld device
- Now set your Wear App as the startup project, build the app and run.
Once installed you should be able to set a break point in Visual Studio to do debugging and test your application. Here’s the output of the sample application:
That’s it! I hope someone find this post useful!