Tuesday, January 20, 2015

Let's get LOST

We just published a post on the Mapzen blog about one of our current projects. Location Open Source Tracker (LOST) is an Android SDK we’ve been working on that provides open source location services for Android. It is a drop-in replacement for the Google Play Services Location APIs that depends only on the Android framework. You can check it out here.

Finding your way with LOST
Finding your way with LOST

Tuesday, January 13, 2015

Recommended Resources

I often get asked to recommend resources for Android development and specifically mapping on Android. So here is a list of some of my favorites.

Android Resources


The Busy Coder's Guide to Android Development
Canonical book of all things Android written and updated continuously by Mark Murphy.

Android Weekly
Weekly email list of new blog posts, tutorials, libraries, announcements, and job postings.

Square Open Source
Collection of open source libraries by Square for building quality Android applications.

Android Maven Plugin
Community driven build system compatible with IntelliJ IDEA and Eclipse.

Robolectric
Android unit testing on your local workstation in the JVM and in your IDE.

Mapping Resources


osmdroid
OpenStreetMap tools for Android.

Mapbox
Open source toolkit for building native map applications on Android.

OpenScienceMap
Free and open maps for Android with the fastest and 100% pure vector maps around.

Location Open Source Tracker (LOST)
Open source drop-in replacement for Google Play services FusedLocationProviderApi.

Pelias
Modular open-source geocoder built on top of ElasticSearch for fast geocoding.

On the Road
Open Source Routing Machine client and navigation utilities for Android.

Wednesday, January 7, 2015

Getting started with Android Studio

It's official! At long last Android Studio 1.0 is a thing. For anyone who is new to Android development or has yet to try Android Studio here is a short walk-through to help you navigate installing Android Studio and building your first app.

Step 0. Install Java 7

If you already have Java 7 installed you may skip to step 1.

Java 7 is required for Android Studio and can be downloaded directly from the official site. Make sure you download the correct package for your computer's operating system and architecture.


Follow the installation instructions for your operating system. When finished open a command prompt and enter "java -version". You should see something like the following:

$ java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Be sure to install the full Java Development Kit (JDK) and not just the Java Runtime Environment (JRE). As of writing this article the current version is 7u71.

Step 1. Install Android Studio

Navigate to developer.android.com/sdk and click on the big green button to download Android Studio.


After the download completes follow the instructions on the screen to install and setup Android Studio. The first time you launch Android Studio you should see the following.


When you are finished with this step you are ready to install additional SDK packages.

Step 2. Add SDK Packages

Out of the box the Android SDK does not come with any platforms included. It does not even include all the tools you will need to build your first app.

Follow the instructions to download and install additional SDK packages including Android SDK Tools, Android SDK Platform-tools, Android SDK Build-tools, Android 5.0.1 (API 21), Android Support Repository, and Android Support Library. Hint: This may take a while.



Once all SDK components have been installed you are ready to begin building your first app.

Step 3. Build Your First App

Follow the instructions in the online tutorial for Creating an Android Project. Once you finish creating your Hello world! project you will need a device or emulator to run your app.

I highly recommend using a real Android phone or tablet if you have one available. If you don't have an Android device available then you can use the emulator.

If this is the first time you've use this device for development you'll need to enable developer options and USB debugging. Here is a short video that might be helpful.


Once your device or emulator is ready you can run the app by clicking on the Run button in the top toolbar.


Choose your device or emulator from the popup window and click OK.


Wait a few seconds for the project to build and deploy and then you should see your app running on your emulator or device. That's it!


Next Steps

You can continue the official tutorial with Building a Simple User Interface and then Starting Another Activity. Or call it a day and crack a cold one. Your choice.

Tips & Tricks

I also recommend checking out Android Studio Tips and Tricks. By far the two most important are Ctrl + Shft + A (command look-up) and Alt + Enter (quick fix).

Command look-up lets you search for any command just by starting to type it. For example if I want to rename MainActivity to something else and I forgot the keyboard shortcut to rename is Shft + F6 I can simply hit Ctrl + Shft + A and start typing "rename".


Quick fix is one of the best things about Android Studio (and IntelliJ IDEA). When you have an issue in your project it is usually shown in red. Hover over the error with your mouse and hit Alt + Enter and Android Studio will fix the problem for you. If it can't automatically fix the issue it will suggest a list of possible solutions.

In this example we accidentally deleted the last letter of savedInstanceState. Android Studio gives us a list of possible solutions including the correct solution which is renaming "savedInstanceStat" to "savedInstanceState".

 

Learning a new development environment can be tedious. Hopefully this guide will help you get started. And if you run into any issues just remember...

"Keep Calm and Alt + Enter"

 

Monday, August 11, 2014

SXSW 2015 PanelPicker voting is live!

The public voting process for SXSW 2015 proposals went live today. For the next two weeks you can influence which sessions will part of the Interactive, Music, and Film programs in 2015.

This year my co-presenter and I are hoping to explore the intersection of location and open source on Android and iOS in a 4-hour hands-on workshop. Show your support by clicking on the link below and giving us a "thumbs up".

Building Location-Aware Apps using Open Source http://panelpicker.sxsw.com/vote/31861

Vote to see my session at SXSW 2015!

Thursday, June 26, 2014

Testing and Pseudo-productivity

I just finished watching Is TDD Dead? - a series of Google Hangouts recorded live on air about a month ago. Inspired by the RailsConf 2014 keynote and subsequent blog post by David Heinemeier Hansson, these conversations include DHH, Kent Beck, and Martin Fowler. After reading books written by all three participants* it was incredibly fascinating to learn more about their personalities and points of view in this format.

One point that is often revisited in the discussions is the concept of TDD as an addictive practice. DHH poses that the classic red/green/refactor workflow leads to regular releases of dopamine in the brain each time a developer writes a new passing test. He asserts that this practice takes too much emphasis away from the production system and leads to test-induced damage including but not limited to bad design, over-testing, and unnecessary layers of abstaction.

While this may be true in some extreme cases, the point that was left out of the discussion is that addictive bad practices are not limited to TDD. There are many ways to trick yourself into feeling like you are making progress when you are in fact not. Other forms of addictive pseudo-productivity include:

  • Getting attached to your first solution
  • Self-imposed scope creep
  • Fancy Implementation Syndrome (FIS)
  • Faster == better

Some developers get a similar shot of dopamine when they think of a solution which leads them to not consider better alternatives. Or when building a feature it may be tempting to add a bunch of unrelated "quick fixes" as a form of self-imposed scope creep. Fancy Implementation Syndrome (FIS) is a concept akin to Fancy Play Syndrome (FPS) in poker and involves using an overly "clever" design when a simpler solution is better.

And I have too often encountered developers who get a rush from building a feature or fixing a bug as fast as possible. Such developers like to proudly proclaim "I can write that in less then an hour!" Hasty solutions are especially dangerous in a system without proper test coverage as the collateral damage can cause countless hours of lost productivity in the long run due to tight coupling, unintended side effects, and decreased readability and maintainability of the system.

I won't claim that TDD is a one-size-fits-all prescription for solving every issue in software development. But the discipline that comes from the exercise of TDD can be an invaluable tool in minimizing bad practices that emerge in the absence of any sort of structured workflow.

References
Rework, Jason Fried and David Heinemeier Hansson
Test Driven Development: By Example, Kent Beck
Refactoring: Improving the Design of Existing Code, Martin Fowler et al.

Tuesday, May 21, 2013

Android is All Grown Up



I just published a post on the AWeber Engineering blog where I break down the recent announcements at Google I/O 2013 regarding Android development and distribution tools and how they are going to improve the way we develop applications.

https://engineering.aweber.com/android-is-all-grown-up/

Which new tools do you think will be the most impactful? Check it out and let me know what you think.

Wednesday, April 24, 2013

Robots in the Orchard



Yesterday I started a new blog to track my experiences deep diving into iOS. After 3+ years of mobile technological monogamy with Android as a user and developer I activated my new iPhone 5 and started writing my first (real) app. Follow my progress here:

http://robotsintheorchard.blogspot.com/

Monday, April 1, 2013

Spacedroid: Android development on the Sputnik 2

Recently I purchased a Dell XPS 13 Developer Edition (code name Sputnik 2) running Ubuntu 12.04 LTS. Dell's project Sputnik, which started as a 6-month exploratory project, has been shipping premier hardware with full Linux support since late 2012. The latest iteration includes a core i7 processor, 8GB memory, 256GB solid state storage, and a beautiful 1080p display, all in a machine about the size of an 11" MacBook Air. But unlike the Air, which I found to be seriously under-powered for Android development, Sputnik 2 is a serious development work horse.


There are a few things that need to be done to get started with Android development on Linux including installing Oracle Java, the Android SDK, and your favorite IDE. The following steps will get you up and running with Android development on Sputnik 2 (and most other Linux distros).


1. Install Oracle Java 6

Oracle Java 6 is the recommended JDK for Android development. Ubuntu ships with OpenJDK installed, rather than the official Oracle implementation. OpenJDK is also incompatible with IntelliJ IDEA (my preferred Android IDE). I followed the steps outlined on AskUbuntu to install and configure Oracle JDK 6.

Once the installation is complete, run the following command in a terminal to verify you are running the correct version of Java.

        $ java -version
        java version "1.6.0_43"
        Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
        Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)


2. Install Linux Android SDK

The Android SDK for Linux is available from http://developer.android.com/sdk. Recently, Google has bundled the Android SDK with Eclipse and the ADT plugin. To download just the SDK proper, click on "Use An Existing IDE" further down the page.

Once the download is complete, you can unpack and install the SDK with the following commands.

        $ cd ~/Downloads
        $ tar xvfz android-sdk_r21.1-linux.tgz
        $ sudo mkdir /opt/local
        $ sudo chmod +rx /opt/local
        $ sudo mv android-sdk-linux /opt/local/android-sdk
        $ chmod +rx -R /opt/local/android-sdk

Now you can start the Android SDK Manger tool.

        $ /opt/local/android-sdk/tools/android

At a minimum, I recommend installing Platform Tools, Android Support Library, and the latest version of the platform, currently Android 4.2.2 (API 17).

After installing these components, add the following environment variables to your favorite shell startup script (.bashrc, .bash_profile, .profile). Also add the Android tools to the executable path.

        # Set Java Home and Android Home environment variables.
        export JAVA_HOME="/usr/lib/jvm/java-6-oracle"
        export ANDROID_HOME="/opt/local/android-sdk"

        # Add Android tools to executable path.
        export PATH="$PATH:$ANDROID_HOME/tools"
        export PATH="$PATH:$ANDROID_HOME/platform-tools"

Finally, some of the Android tools (like adb) require the 32-bit compatibility libraries on Linux. Run the following command to install these packages.

        $ sudo apt-get install ia32-libs


3. Install IntelliJ IDEA

Download the latest version of IntelliJ IDEA Community Edition from http://www.jetbrains.com/idea/download. This free and open source edition includes full Android development support.

Unpack and launch the app using the script idea.sh in the /bin subdirectory.

        $ cd ~/Downloads
        $ tar xvfz ideaIC-12.0.4.tar.gz
        $ mkdir ~/Applications
        $ mv idea-IC-123.169 ~/Applications
        $ ~/Applications/idea-IC-123.169/bin/idea.sh

You can also add this script to the executable path or add a symlink to /usr/local/bin for convenience.

        $ cd /usr/local/bin
        $ sudo ln -s ~/Applications/idea-IC-123.169/bin/idea.sh idea

When you launch IntelliJ IDEA for the first time you will need to configure the Java and Android SDKs. First we will configure the JDK:
  • Click Configure > Project Defaults > Project Structure
  • Under Platform Settings, click SDKs
  • Click the plus (+) sign to add a new SDK
  • Choose JDK, then select the folder for java-6-oracle and click OK
  • Type in the name "JDK 1.6" then click OK
Next we will configure the Android SDK:
  • Click Configure > Project Defaults > Project Structure
  • Under Platform Settings, click SDKs
  • Click the plus (+) sign to add a new SDK
  • Choose Android SDK, then select /opt/local/android-sdk and click OK
  • Choose JDK 1.6 and Android 4.2.2 then click OK
  • Click OK to finish

4. Build and Run Hello World!

Now that Oracle JDK 1.6, Android SDK 4.2.2, and IntelliJ IDEA are installed and configured we are ready to build and run our first Android app.
  • Launch IntelliJ IDEA
  • Choose "Create New Project"
  • Enter project name "Hello Spacedroid"
  • Enter project location /home/[username]/IdeaProjects/hello_spacedroid
  • Click "Next" button
  • Change Target Device setting to USB device and click "Finish" button
  • Attach a device via USB
  • Run the configuration for "hello_spacedroid"
Android development on the Sputnik 2 is now ready for takeoff.

Wednesday, February 27, 2013

HowAboutWe... Build an Android App

HowAboutWe Dating for Android was successfully launched in December 2012. As with any new product development and subsequent release process it was not without its challenges.

The article 7 Key Questions To Ask When Taking Your App From iOS To Android was written by the Android team at HowAboutWe to chronicle our development process. In it we explore some of the lessons learned when building a robust and feature rich application following official Android patterns and conventions that is also on brand, especially from the perspective of a company with an existing web and iOS presence.

Here is a presentation I gave at Android Alliance Philadelphia based on the same article. I hope other Android developers, designers and entrepreneurs alike find this information helpful when embarking on a similar undertaking.


You can install the current version of the HowAboutWe Dating from Google Play here. I would love to hear your feedback in the comments-- on the article, the presentation, and the app.

Sunday, November 4, 2012

Connected

You often hear about how connected we are in the digital age. It is easier than ever to stay in touch with people and events near and far with the advent of email, cell phones, and social networks. The 24-hour news cycle has gone viral. If I want it now I can Buy Now.

Yet in the wake of hurricane Sandy and a week without electricity, cell service, or access to the internet, I can honestly say I felt more connected in many ways while being disconnected from the digital world. More connected to friends, family, neighbors, and my local community.

When is the last time you had a conversation at length with someone close to you that was not interrupted by a phone call, text message, email, or status update?

And now we return to the "real world" and the ongoing quest of how to reconcile these two kinds of connected.