Getting Started with Bitrise.io

Problem:

Most automated build servers don’t play well with mobile apps. Even after considerable configuration they still require a lot of up work for each new app.

Solution:

A friend of mine recently introduced me to Bitrise.io, an automated build server specifically built for mobile (Android, iOS & Xamarin). I’m happy to say that I was up and running in less than 30 minutes. With set up complete, adding a second project took just minutes.

Why do you need a build server?

Build servers are very useful and help ensure the stability of your codebase. If you’re code doesn’t compile or you forgot to check in a necessary resource to version control, your build server will notify you that something is wrong. Build servers also allow you to automate builds for QA and will keep a record of release builds. Still not convinced? Check out this blog.

Adding Your First Android Project to Bitrise.io

You can easily hook Bitrise.io up to your existing GitHub or Bitbucket account. If you host your own Git server, setup is as simple as adding an SSH key to your authorized_keys file.

Repo Setup

After you’ve added the SSH key as a new line to your authorized_keys file, select the branch you want to use. Select a stable branch that builds successfully on your local machine.

Repo Setup

I ran into a hiccup at this point. The project I added was one that I created almost a year ago. The gradle wrapper was too old to work with Bitrise.io and the error was a bit cryptic.

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
   > Gradle version 2.2 is required. Current version is 2.10.
     If using the gradle wrapper, try editing the distributionUrl
     in /bitrise/src/gradle/wrapper/gradle-wrapper.properties to
     gradle-2.2-all.zip

I was using version 2.2.1 and the current version is 2.8 so I’m not sure what the numbers in the error actually represent. A quick Stack Overflow search yielded the following result.

The solution

Update your graddle-wrapper.properties file:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip

I also updated to gradle 1.5 in my build.gradle file for good measure:

classpath ‘com.android.tools.build:gradle:1.2.3′
classpath ‘com.android.tools.build:gradle:1.5.0′

After checking in the code, everything compiled successfully! My ScoreKeeper app for Android Wear is now set up on Bitrise.io.

Android News for June 2015

Android Design Support Library

The design support library makes it easy to use material design when building Android apps. The best part, it’s compatible all the way back to Android 2.1. This support library includes a better navigation drawer, collapsing navigation bars, snack bars and a number of other key components of material design. Combine this with a view pager, recycler view and the swipe to refresh library for a complete base application.

Google developer blog:
http://android-developers.blogspot.com/2015/05/android-design-support-library.html

Sample code:
https://github.com/blackcj/DesignSupportExample

Developing for Android: Technical Guide

Google released a collection of best practices and common pitfalls written by the Android framework and runtime teams. This is a must read for all Android developers. It’s only eight chapters long so you have no excuse not to read it.

https://medium.com/google-developers/developing-for-android-introduction-5345b451567c

Free Material Design Icons

Need icons for your Android, iOS or Web app? Google has provided a great collection of icons that are free to use:

https://google.github.io/material-design-icons/
https://www.google.com/design/icons/

Stay tuned for more Android news and examples.

Cell Number Formatting with Google Apps Script

Problem:

The setNumberFormat function within Google Apps Script is not well documented in the API reference documentation. This function accepts a wide range of parameters in a single string that can be used to specify the format for a range of cells. Knowing the accepted formats will give you control over the data in your cells when using Google Apps Script for Google Sheets.

Solution:

The following examples demonstrate how to use various string patterns to define the format of a particular range within your active spreadsheet. You can set the formatting of a single cell, a whole column starting from a specific cell or an entire spreadsheet. Additional resources can be found on the Google Sheet support page for number formats. It would be nice if there was a link to that support page from within the API reference.

Plain text for a single cell:

// Use these first two lines for all four examples
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Single cell
var cell = sheet.getRange("B2");

// Plain text
cell.setNumberFormat("@");

Date for single column

// Single column, select every row from 2..n in column B
// To select a limited range put the ending row number (“B2:B10”)
var column = sheet.getRange("B2:B");

// Simple date format
column.setNumberFormat("M/d/yy");

Additional details about accepted date formats can be found here: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

Currency for entire sheet:

// Select all rows and columns from a spreadsheet
var range = sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns());

// Money format
range.setNumberFormat("$#,##0.00;$(#,##0.00)");

Additional currency and number formats can be found here: https://support.google.com/docs/answer/56470. You can specify up to four parts for custom number formats; positive, negative, zero and text. You can even add color by including one of the compatible colors in the string format.

Custom number format with color

// Number format with color
var row = sheet.getRange("A1:D1");
row.setNumberFormat('$#,##0.00[green];$(#,##0.00)[red];"zero";@[blue]');

// Sample values
var values = [
   [ "100.0", "-100.0", "0", "ABC" ],
];
row.setValues(values);

Number format example with color.

This gives you a quick way to set conditional formatting without having to write custom logic. You can use this to quickly identify problematic data.

Product Review: Moshi ClearGuard for the MacBook Pro

I use protective covers on all of my electronics. I recently purchased the Moshi ClearGuard keyboard cover for my MacBook Pro. In addition to protecting against spills, it also helps keep the keys free of grease. I have oily fingers which translates to shiny keys within months without a cover. This was a must have product for me.

Moshi ClearGuard Keyboard Cover

Moshi Keyboard Cover (lifted slightly off the keys)

Pros

Easy to Install

Compared to other keyboard covers, this one was easy to install and fit perfectly out of the box. Installing the cover almost felt too easy. You just take it out of the packaging and set it on the keyboard. That’s it. I searched the box looking for instructions and ended up watching a YouTube video to be certain that I had not missed a step. No adhesive tape or instructions needed.

Washable

The keyboard cover is durable and easy to clean. Just lift the cover off the keyboard and wipe it down with warm water. Make sure to let it dry completely before putting it back on the keyboard. I’ve washed mine a couple of times in the past month and it still fits great.

Protective

Having the cover on my keyboard gives me piece of mind. In addition to protecting against spills, it also collects dirt, crumbs and grease. I frequently eat lunch at my desk and no longer have to worry about pasta sauce or cookie crumbs getting into my keys.

Cons

Cost

At $25, it’s not cheap. For comparison, a similar cover for my old Fujitsu laptop was $14. Either way, if you protect even a single spill, it would pay for itself. The cover has the added benefit of increasing the re-sale value of the device by keeping the keyboard looking new. It would be great to see this product closer to the $15 marker. Unfortunately, I wasn’t able to find any quality competitors for the MacBook Pro.

Easy to Remove

This could be a pro or a con. The cover rests on top of the keyboard. The cover for my Fujitsu laptop sealed around the edge with double sided tape. This helped keep it in place and further protected from seeping liquid (in the event of a spill). On the other hand, it does make the cover easier to clean.

Makes the Screen Dirty

As with all protective covers I’ve owned, the dirt tends to rub off on the screen. This is not permanent and can be easily wiped off but an inconvenience nonetheless. Something I’m gladly willing to do for the piece of mind it provides. I keep a micro fiber cloth in my bag to use for wiping off the screen once a week.

Bottom line, protect your investment with a Moshi keyboard cover.

Full product name: Moshi ClearGuard MB for Pro 13″,15″,17″ White MacBook (2009) MB air 13″ US Layout (99MO021901).