Around a week ago, I purchased a LG G Watch, and have found it to be a pretty nifty device. Being able to see the time in addition to my phone’s notifications on my wrist is very useful, and after about a week I can see why wearables are a natural extension to cell phones and technology as a whole.
As soon as I found that Android Wear ran a modified version of Android, I was curious to see what hackery could be done with it. Here’s something cool that I was able to get working: a NES emulator.
The first step to messing around with Android Wear is to enable all of the debugging options. These will allow you to install applications and access debugging tools from your computer.
First, make sure that your Android phone has debugging mode enabled by going into Settings -> About phone, and hitting the Build number entry several times. A toast notification will pop up, informing that you have become a developer. Congrats!
You will now notice that a Developer Options entry has appeared under Settings. Open that, tap On at the top, and enable USB debugging. Accept the dialog that follows, and you’re in business.
Debugging is now enabled on your phone, but not on your watch — yet. To accomplish this, navigate to your watch’s Settings menu by tapping on your watchface, scrolling all the way down to the bottom of the list, and selecting Settings. Here, click About and do the same Build number trick as above.
By going back to the previous menu by sliding from left to right, you will see the same Developer options category that you saw on your phone. Here, enable both ADB debugging and Debug over Bluetooth.
One final step is needed: go back to the Android Wear application, and in settings, scroll down to the bottom and enable Debugging over Bluetooth. This will allow you to run debug commands, like installing applications, by connecting your phone to your computer as opposed to your watch.
Setting up ADB
ADB is the Android Debug Bridge, which allows you to do all sorts of cool things to your phone, from installing applications, sending and receiving files, to changing system settings. If you haven’t installed it on your computer, follow this CyanogenMod guide here.
Once it’s installed, open a shell, command prompt, or terminal—whatever terminology your OS uses. First, let’s make sure your phone is connected:
bender:~ james$ adb devices
List of devices attached
Enter these two lines, which forward the adb connection between your phone and your watch to your computer.
bender:~ james$ adb forward tcp:6666 localabstract:/adb-hub
bender:~ james$ adb connect localhost:6666
connected to localhost:6666
Now, run adb devices again, and you should see, in addition to your phone, your watch:
bender:~ james$ adb devices
List of devices attached
If you see a “localhost:6666" entry, you’re in luck: your watch has been successfully connected to your computer. You can now run any adb commands to your watch, as long as you pass the flag “-e.”
Now that debugging is all set up, you can easily install Android applications on your watch, whether built for Wear or not. Note that, because of API limitations on the current version of Android Wear, regular Android applications run on the watch will be unable to access the internet, and may crash. With that out of the way, let’s start having some fun on our watch.
Let’s start by installing a NES emulator, NESoid, so we can do some retro gaming on our watch. Start by downloading the APK here, and save it to some accessible place on your computer. Then, run the adb install command:
bender:~ james$ adb -e install Downloads/Nesoid.apk
65 KB/s (327545 bytes in 4.869s) pkg: /data/local/tmp/Nesoid.apk
Now, we can open it on our watch. Tap the watch face, scroll down to Start..., and choose Nesoid. The main screen of the app will open, as seen below.
Setting a Custom DPI
One problem that we’ve just run into is that, well, everything is very big! In the ROM listing that first appears in the app, only one option is visible, if even that. Because of the small screen size and default DPI (dots per inch) values of current Android smartwatches, regular Android apps are just not suited to run on this small a screen. There is one thing we can do, though.
bender:~ james$ adb -e shell wm density
Physical density: 240
Run the adb density command on your watch, as shown above, and you will see the current DPI value that your watch is using. This value controls the size of user interface elements on the display: the smaller the value, the more items that fit, the larger the value, the larger each individual item appears. Take note of this value, so that you can revert to it later if needed. For my G Watch, the default is 240. We can set a custom value like so:
bender:~ james$ adb -e shell wm density 200
You’ll notice that the watch takes a second to readjust, and everything appears smaller. This does cause some visual quirks to show up within the Wear interface, such as larger-than-usual paddings and black bars, so it’s best to keep this DPI change temporary. Now, let’s try opening the Nesoid application again:
That’s a bit better. You can continue to try lower and lower values if you would like, although this will make text very tiny and the regular Wear interface almost unusable.
Adding Files and Using the Shell
There’s one more step that we need to accomplish before we can play games on our watch, and that’s being able to access the filesystem. As a NES emulator, Nesoid requires that ROM files be available on the /sdcard of our watch. We can do this easily using adb push. Search online and download a ROM file of a game that you want to play, and then push it to the filesystem of your watch like so:
bender:~ james$ adb -e push Downloads/SuperMarioBros.nes /sdcard/
46 KB/s (40976 bytes in 0.860s)
When the command is finished, the file has been successfully added to the watch’s filesystem. As is with any other Android phone, you can retrieve files from the filesystem, as well as open a Linux shell through adb as well.
bender:~ james$ adb -e pull /sdcard/SuperMarioBros.nes .
52 KB/s (40976 bytes in 0.761s)
bender:~ james$ adb -e shell
shell@dory:/ $ cd /sdcard
shell@dory:/sdcard $ ls
shell@dory:/sdcard $ mkdir ROMs
shell@dory:/sdcard $ mv SuperMarioBros.nes ROMs/
shell@dory:/sdcard $ ls ROMs
Now, with a custom DPI and installed ROMs, you can sit back and do some old-school emulation on your wrist.
If the controls are too big, try lowering the DPI some more. On my G Watch, I found 150 to be a good level.
If you have a Bluetooth gamepad, you could probably set that up and not use the on-screen controls at all. If anyone gets this working, let me know.
When you’re done playing, you will have to force the application to stop manually, like so. (I’ve also found that double tapping the screen with two fingers closes most applications, but it doesn’t always work.)
bender:~ james$ adb -e shell am force-stop com.androidemu.nes
If you don’t know the package name of the application, you can find it by running ps in a shell.
bender:~ james$ adb -e shell ps
Might want to reset the DPI, too:
bender:~ james$ adb -e shell wm density 240
Happy hacking, and keep the charger handy!