When I decided to try my hand at android wear development I ran into some issues during the initial setup and thought it might be a good idea to help out others that may be trying.
My first attempt to use eclipse was a total bust. I am sure it can be done, but because the app needs to be packaged for both a phone and the watch, two apps in one eclipse were causing more trouble than it’s worth. So I decided to try using Google’s own software Android Studio.
Assuming you have already downloaded and installed android studio and the latest android SDK here is how I began:
The tutorial here is a great place to start and it will show you how to accomplish the first step, connecting your phone to your android wear emulator:
http://developer.android.com/training/wearables/apps/creating.html
I had set up an emulator for the watch app and my Sony Xperia ultra for the phone app. This went pretty smooth, but if you are new there are a few things you need to do first.
I had already installed the USB drivers from previous development attempts, but for those just getting started you can download them manually here:
http://developer.android.com/sdk/win-usb.html
A few things to consider:
- Make sure you phone has USB Debugging enabled. This can be found in developer options under settings. On Android 4.2 and higher, the Developer options screen is disabled by default, you have to click on Settings>About Phone and tap Build number 7 times.
- When you first connect your device you may see a message on the screen indicating a fingerprint match. If you do not accept this you will not see your device when you go to test out your app.
Now that you have your watch & phone talking to each other it’s time to create your app.
CREATING YOUR FIRST PROJECT
I ran into some more issues here. From my understanding of the numerous forum posts and websites I visited trying to troubleshoot the issues, the template that is packaged with the android studio has already been depreciated and does not work when you try to compile it.
Rather than debugging code that doesn’t work I decided to use a skeleton app and found a brilliant starter here:
https://github.com/sveinungkb/wear-test
To import the project, select “import project” from the Android Studio file menu or splash screen. You should now be presented with a number of folders including: shared, wear, & mobile. If you do not have the ability to “run” wear or mobile follow these steps:
- Ensure your SDK is downloaded and up to date. In Android Studio select Tools>Android>SDK Manager. I have installed the Android API 8, 19 & 20 (20 being for Android Wear specifically) as well as the current tools & most of the extras.
- If you had set up a path to Gradle it may be complaining about versions. Under file>settings select Gradle and ensure Gradle home is blank. Select apply and it should start to rebuild.
At this point you should see, under the run dropdown, the options for wear and mobile.
Time to try it out, select ‘wear’ and click run. If you have already setup an emulator you will have the option to select it here.
Note: I did find that if you launch the emulator when running the app it will fail to install the apk, if this happens just run it again without closing the emulator.
If you see ‘Ready!’ you have done it. The developer of the skeleton above has already packed in a goody or two in the form of a roughed out communication between the phone app and the wear app. If you followed the instructions I provided at the beginning your phone and emulator should already be connected, if you launch the phone app from android studio you will see the communication in the logs and on the device.
You’re ready to start developing your app. In part two, I will go through some basics using android studio.