Category Archives: Android

Android + Glass Meetup

Did I mention that I started up a group called Android + Glass, a meetup which is focused on developing apps for Android and Glass over in the Tysons Corner area?

In addition to iOS, I also like to develop for Android. I’m also a Glass Explorer (I got in on the second round thanks to my buddy Andrew at Near Infinity.) Since the native Glass SDK, the GDK, is built on top of Android, I get to leverage all of that for Glass dev.

I also have a passion for getting developers together. I’m not sure exactly why, but I think it is just great to meet other programmers and talk with them. Maybe so we don’t feel so alone in the world? Not sure.

Also it is nice to have a meetup group that is close by. Around where I live and work, traffic is brutal. We regularly tie with Los Angeles for the worst traffic in the USA. It’s so bad that a guy from Manhattan said that he thinks our traffic is bad. Manhattan!

So I’ve started a local Android and Glass (and likely soon Wear) development group in the Tysons Corner area. We’re meeting at Capital One DIG, which is the building next to the infamous “shopping bag building.” It is kind of connected to Tysons Corner via a walking bridge too, which is nice if you want to go there to shop or eat beforehand.

Why start another group? Proximity and focus. There are other groups that discuss Android and Glass, but none in the immediate area. They usually meet either near Dulles or in downtown DC. While that seems close on a map of the USA, it can be an eternity in rush hour traffic.

Our focus is also purely on Android and Glass (and Wear) development. We don’t really talk much about other Google technologies unless they build on Android like Glass. We talk a bit about Glass usage because it is so new. We are also exploring related wearable technologies because the whole wearable space is pretty new. But we always look at them through a development lens: how can we write apps for that platform? What applications make sense in that context? What are the common techniques when developing with that API?

I do like the other local groups, namely the GDG-DC, Google Glass DC and DC Droids. I will likely go to their meetings occasionally and I encourage you to go there as well, especially if you live close to them. If you love all Google technologies, GDG is the best bet. If you like to explore all aspects of Glass, not just the programming side, Google Glass DC is probably better. But I hope to make a nice cozy regular meetup for Android developers and Glass developers here in the Tysons area.

Speaking of which, we have already had two meetings and we will have another one on April 29th, where we’ll be talking about mostly about Android and Bluetooth LE (and we’ll also have an Oculus Rift on hand to compare and contrast vs Glass, especially the SDKs.) We will have regular meetings, which I think is important for a meetup – as I’ve learned from Jose, the organizer of NSCoderNightDC. The meetings after that are scheduled for May 21 and June 18.

If you are interested in makings apps for Android or glassware for Glass, I encourage you to join the meetup group and RSVP for one of the upcoming meetings. Did I mention there will be free pizza and drinks courtesy of Capital One? :D

If your Emulator doesn’t show up in the Devices list…

Sometimes the Android Emulator that you just started up does not show in the Devices list in the DDMS Perspective of Eclipse. If that happens to you (like it just happened to me), then do the following in your command line to get it to show up:

adb kill-server
adb start-server

You should see this output:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *

Then your Emulator instance should show up in the Devices list.

I’m not exactly sure why this happens, but it has to do with adb (the Android Debug Bridge) going into a bad state. The kill-server/start-server combo serves to reboot it and back into a good state.

I’m giving a talk about the Android Emulator at AnDevCon Boston

Good news! I’ll be giving this talk again at AnDevCon San Francisco in November. I’ll be updating it based on questions I received in Boston, recent developments from Google and Intel. Also there are some things that I wanted to include in the original that I’ll be adding. Come check it out live in San Francisco!

Two weeks from now, on May 31st, from 2:00 PM to 3:15 PM, I will be giving a talk about the Android Emulator at AnDevCon Boston. It is titled “Becoming More Effective with the Android Emulator”, but in order to spice things up a bit, I’m going to give a it a MythBusters-style twist. The subtitle is “Android Emulator Myths…Busted!”

I’ve really fallen in love with the Android Emulator as part of my Android development workflow. I find it a lot easier to work with than switching over to a device, especially with the advancements that have been made in the past year or so. So I really want to share my insights in how to make it work well for everyone. I’m hoping it encourages more people to discover how useful the Emulator is as a tool in the Android toolbox and use it more regularly.

If you want to attend a pure 100% Android development conference, definitely check out AnDevCon. I’ve been to the previous two events and really enjoyed all the content as well as meeting more of the Android community in person. Also, if you use code “DELAROSA”, you should get an additional $200 off the registration.

Hope to see you there!

Will the Android Developer Tools for Eclipse continue to exist?

Here’s a paraphrased quote from the Q&A session after the What’s New in Android Tools session at Google I/O 2013:

We will continue to support Eclipse. We are focusing on the Android Studio to get that up to speed. We will be changing the build system of ADT (Android Developer Tools) in Eclipse to use Gradle (from Ant.)

- Xavier Ducrohet, Android Developer Tools Team

How to fix problem when app won’t start when testing with calabash-android

I’ve been starting to use calabash-android, which is a way to run cucumber tests on Android. It requires Ruby Gems and Xcode Command Line Tools on Mac, which installed fine. However, when I ran the first sample test, then I noticed the app did not start. I looked at the output and saw that this error showed up:

App did not start (RuntimeError)
/Library/Ruby/Gems/1.8/gems/calabash-android-0.4.3/lib/calabash-android/operations.rb:364:in `start_test_server_in_background'

I looked around for the solution and did not find, so I tried a few things. It turns out to be an easy fix. In your Android app’s manifest, aka AndroidManifest.xml, include the line:

<uses-permission android:name="android.permission.INTERNET" />

inside of the manifest tag, after your application tag.

Why does this work? The reason is because Calabash-Android (and Cucumber in general) uses HTTP to communicate between the host computer and the target application. Since Android apps do not have permission to communicate via HTTP by default, the test fails to start.

java.lang.ExceptionInitializerError when using Mockito on Android

So you’re being a good Android developer, using JUnit 3 tests [Sidenote: JUnit 4 does not play well with the JUnit runner in Eclipse for Android currently] and using Mockito to create mocks to make sure you’re focusing on the class that you’re testing. However, you run into a java.lang.ExceptionInitializerError when running your tests. This is pictured below. What should you do?

tl;dr –

To use Mockito on a device or emulator, you’ll need to add three .jar files to your test project’s libs directory: mockito-all-1.9.5.jar, dexmaker-1.0.jar, and dexmaker-mockito-1.0.jar.

“Mockito on Android” from the Square Engineering Blog

Put those 3 JARs linked above in a “libs” directory in your test project.

The root cause of this is that the classes that Mockito makes needs to interact with dex, which is what Android uses to create its classes. This can be done with Dexmaker and the Dexmaker/Mockito integration. Once you add in those 3 JARs into your libs directory, just do the refresh/clean project dance and then you should be good to go.

Special thanks to Jesse Wilson (@jessewilson) for making DexMaker and integrating Mockito with Android!

Parcelabler helps you create Parcelable implementations for your Android classes

If you have ever had to implement the Parcelable interface for one of your Android classes, you will find that it is tedious. It is especially tedious the more fields your class has. So usually you don’t do it unless you have to pass it in an Intent to an Activity or as a Bundle of arguments to a Fragment.

Enter Parcelabler, which is a web-based tool that creates Parcelable implementations for you. Just copy the portion of your class which has the fields into the Code textbox and then press the Build button. I’ve had good results with it, although it is best at primitive fields. I usually edit the class in a text editor like Sublime Text to make it so that only the class and fields are entered.

Thanks to Dallas Gutauckis for creating this helpful tool!

Nexus 7 Won’t Boot Up

I’ve recently been having problems with my Nexus 7 not booting up after it completely runs out of battery. Specifically – even if I have charged it overnight, if the power is off and I click the power button, then it does not turn on!

I’m not sure if this is related to 4.2.1, but this problem didn’t seem to occur with 4.1.1. I’ve got the 8GB version of the Nexus 7.

To solve it, press and held on to the power button until it starts up (for approximately 30 seconds.)

Note that Asus has a support page which mentions this titled Nexus 7 won’t start up. I agree with their recommendations, but I’d add that you’ll probably need to press and hold it for longer than what they recommend (around 30 seconds vs their recommended 15).

Update: after a quick search, a thread on Android Enthusiasts titled Nexus 7 wont boot after complete discharge corroborates my findings.

AnDevCon III Review

I attended AnDevCon III in May 2012 as my first Android-related conference, about a year and a half into my Android experience. I have attended many developer conferences before so I thought it’d be interesting to compare it to those. I’ll be attending AnDevCon IV later this week, so obviously I was pleased with what I experienced, but I wanted to note down what my thoughts were from that first experience.

I’ve been to a variety of conferences:

  • JavaOne, one of the biggest but also one of the most “corporate”
  • WWDC, the best place to interact with Apple engineers and other Mac and iOS developers
  • EclipseCon, which was focused on a single open source project, Eclipse
  • No Fluff Just Stuff, sort of an anti-JavaOne, where the speakers are all practitioners
  • C4, sort of an anti-WWDC, where the speakers were mostly Mac indies

AnDevCon feels a lot like EclipseCon. Partly because this is because it was held at the Hyatt Regency in Burlingame, where I once attended EclipseCon 2005. More substantively, a lot of companies participate in the conference, which gives it an interesting and varied vibe. This is compared to single-vendor conferences like WWDC or Google I/O, where you get the perspective of only one company mainly.

Google engineers and evangelists do play well with AnDevCon, however. They present some of the sessions, which are prominently marked on the scheduled as “Google CLASS”. Kirill Grouchnikov‘s Responsive Mobile Design in Practice was particularly insightful in the project that I was working on at the time. I had seen his slides, but they did not make as much sense as when I had heard him speak live about responsive design. Now that we can nest fragments within fragments as of the 4.2 SDK, I wonder what he would say about that.

There are a large amount of sponsors. You might think that this is a bad thing if you have attended a conference that had lots of sponsored talks. However, the organizers seem to be aware of this and have helpfully marked all the talks that as “Sponsored by XYZ”. I actually liked some of those, particularly the ones sponsored by Intel, where I learned more about the HAXM-accelerated emulator and Sony, where they taught us about the Sony SmartWatch SDK.

I normally don’t like Exhibit Halls at conferences. Sure, you can get a lot of free goodies. OK, I admit it – half my wardrobe is conference t-shirts. But the booths usually are kind of boring. However, at AnDevCon, there were a lot of interesting exhibits. I’m not sure if it is because the industry is expanding so rapidly or because I just like gadgets, but there were some things I hadn’t seen before there, like the Epson Android-powered glasses (sort of a bulky early release of Google Glass) or the Qualcomm developer boards, which are entire Android systems on a large PCB.

I met a lot of interesting people, especially at Square’s Android Dessert Bash. Everyone was fired up about Android and there were a lot of different perspectives there. There were folks from the phone manufacturers like HTC, independent consultants, authors, trainers, regular developers and also platforms like Nook. It was pretty friendly atmosphere but I didn’t see as many night parties as I have seen at other events, but maybe it’s because I didn’t know as many people.

I honestly did not know what to expect and only knew one person who was going to the event, Dave Smith, who gives talks on Android accessory development. I was pleasantly surprised with my overall experience. The only con is that the official conference t-shirt was sponsored – in my opinion, it’d be nicer if it just had AnDevCon on it. However, Square gave away one that was more subtle and had all the different dessert icons on it, which was my favorite.

I’m looking forward to AnDevCon IV, happening later this week, which promises to be even bigger and better, featuring keynotes from Amazon, Google and Facebook.

Fixing Copy in Eclipse

I use Eclipse for Android development and one of the issues I have come across is that sometimes Command-C on Mac (Control-C on Windows) doesn’t work properly. I will copy, but paste will paste what was previously in the buffer, not what the latest I wanted.
My previous workaround was to hit Command-C twice which always seems to work. This is a pain, however.
Fortunately I came across this blog post: Ctrl+C to copy does not always work in Eclipse which describes a simple fix: Unbind the copy command in Eclipse. Note that this also applies to the Android Developer Tools distribution, since it is built on Eclipse.

The workaround is to unbind the Copy command in Eclipse. The reason this works is that the native Copy will be used instead.

To do so, go into the menu:
ADT or Eclipse
> General
>> Keys

Search for Copy
Select Copy
Press the button “Unbind Command”

Here are some screenshots:

Before (Copy is bound to a shortcut key):
Copy command bound to a shortcut key

After (Copy command no longer bound to a shortcut key):
Copy command no longer bound to a shortcut key