donderdag 13 november 2014

Deploying an Android Wear app to a device

When you're developing an Android app, it's nice to test the result on an actual device. When developing Android Wear apps, this might even be more relevant because of the importance of the user experience (i.e. smaller screen size).

This post contains some steps/information which you might find use full in developing and deploying app to a wearable device using Android Studio.

Note: we assume that developer mode has already been activated on your handheld device.

Enable Debugging on SmartWatch (LG G-Watch)

Enable Developer Mode


  • Open Settings;
  • Open About; Find Build number and tap on it 7 times;
  • You're done when a toast popup appears with the message, "You are now a developer!" Swipe right (to go back) to the Settings menu. 

Enable ADB-debugging


  • Open Settings;
  • Open Developer options; 
  • Find and set ADB debugging to Enabled. You'll be asked if you're sure you want to enable. Tap the checkmark button to confirm.
  • Find and set Debug over Bluetooth to Enabled.


Enable USB Debugging on Android Smartphone

On the Android Wear app on your handheld, go to settings, and enable "Debugging over Bluetooth".



Connect the Smartwatch via ADB

Open a Terminal, if required navigate to the Android SDK Platform Tools,  and enter following commands:

$ ./adb forward tcp:4444 localabstract:/adb-hub; 
$ ./adb connect localhost:4444

Run the wearable app


  • In Android Studio, select your wearable app from the Run Configurations;
  • Press the "Play" button next to the selected configuration;
  • When the windows appears with the connected devices, you will see the wearable listed as a deployable device;
  • Select the wearable device and continue;
  • You can check in the "Run" status window if the application is successfully deployed;


woensdag 22 oktober 2014

Changing command line switches for Chrome on Android

While we were developing a web application, we ran into a little "snag" when a (Nexus 5 using a) Chrome browser tried to access our web application using a reversed proxy.  For some reason we received a Connection Closed after downloading the headers with some 8 kb of (corrupted) data.

When we narrowed it down that the data was compressed, we found out that Chrome enables SDCH by default, which is only supported by ... Google.  To narrow down the problem, we checked if we could access the server directly (worked via a VPN) and with different browsers (Opera and Firefox). When we used Firefox, it all worked perfectly (why? WebKit vs Gecko Engine...).

Because we actually wanted to point-out the problem, we wanted to be able to switch of the SDCH when using the Chrome browser (we used Chrome 38.0.2125.102 on Android 4.4.4). Here are the different steps we used:

Prerequisite:
  • You need to have root access on your Smartphone (we rooted a Samsung Galaxy Nexus with a Cyanogenmod);
  • You need developer access to your Smartphone;
  • You need to have adb (Android Debug Bridge) installed;
  • You need to have a good understanding of Linux/Terminal/VI;
As they say, with great power comes great responsibility. So please be careful on what you do with the root access!

Connect your device via a USB cable and start a Terminal. Connect to the device using:

$ ./adb shell

Change to root:

shell@maguro:/ $ su 


In your prompt VI a file called "/data/local/chrome-command-line" a

root@maguro:/ # vi /data/local/chrome-command-line 

Add this line (or whatever switches you may need) to this file:

 
--enable-sdch=0 --enable-sdch-over-https=0
~
~
~

Quite VI (:wq) and stop the Chrome instance running on your Android device. If you open the Chrome browser and navigate to "chrome://version", it should display the newly added switches  just below "User-Agent".