Jenkins builds with a different Java version

We have a Jenkins server taking care of CI for an Android project. In the server we were using Java 7, but since we updated a few dependencies we needed Java 8 to run some Gradle plugins. After the change, we suddenly started to get this error in the builds:

* What went wrong:
A problem occurred evaluating project ':my-project-app'.
> java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

After googling it, I found the following SO answer, pointing us to the need of Java 8 (major version 52): How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version.

So, given that:

  1. server has both Java 7 and Java 8 installed
  2. Jenkins is configured to run using Java 7, and changing may pose some problems (and currently any failure could put our schedule in jeopardy)

we decided to just run Gradle script using Java 8. To configure it, the following change was done to the configuration of the job: in section Build Environment, enable Inject environment variables to the build process and add the following to Properties Content:


in our case:


And hit Rebuild!

Problems with Instant Run (Android Studio 2.0 beta 4) and Retrofit

This morning I was playing with a toy app I have which uses Retrofit, and I’ve found the following problem with it (and Instant Run):

02-16 07:41:55.550 2976-2976/ A/art: art/runtime/] Throwing new exception 'length=227; index=1017' with unexpected pending exception: java.lang.ArrayIndexOutOfBoundsException: length=227; index=1017

The exception was in the call itself, so it was either Retrofit doing strange things or something deeper. I found the problem to be because of some interaction between ART and Instant Run, and it was already reported.

The original reporter has opened a bug in the AOSP and it’s still unsolved. See also (Retrofit).

All in all, currently there is no fully reliable solution. So, if you find this problem in a call using Retrofit, the best course of action is to disable Instant Run and rebuild. Preferences -> Build, Execution, Deployment -> Instant Run -> (uncheck) Enable Instant Run to hot swap code/resource changes on deploy (default enabled)

Disable Instant Run

Hilarious Git plugin: git-blame-someone-else

This plugin allows to change the commit author information. Super-useful to avoid to be the one to blame for bugs and mistakes. ;)

“I love git-blame-someone-else!!” –Linus Torvalds says*

*Linus Torvalds didn’t really approve of this. It’s a joke to prove it works. See his fake commit here

Easily manage windows in OS X

I’ve been using OS X for many years already, and as my primary computer OS for almost a year. Before that, I used to spend time with Windows (like 90% of it), Linux (for server) and OS X.

There are two things that I missed after switching from Windows (last version I regularly used was 8.1) to OS X (I started to regularly use it on Tiger), being a heavy keyboard user: the way window cycling works on Windows, and Windows snap (available since Windows 7, including shortcuts).

Window switch

Window switch shortcut on Windows (Alt+Tab) cycles through all your windows, in usage order, but on OS X (Cmd+Tab) cycles through applications. There is a second shortcut, which usually is assigned to Cmd+`. This shortcut is quite cumbersome, at least on Spanish keyboard layout (maybe also on English layout too): as soon you enter in a text field of any kind, if you press this shortcut you get the ` character, waiting for you to complete an accented letter (yes, in Catalan and Spanish languages we have such a thing). Additionally you cycle through your windows immediately, without preview, and without remembering your usage order.

There are two solutions here:

  • change the shortcut in System Preferences (preview and usage order still missing here),
  • use Witch (thanks to Jaume Sánchez for pointing me this out).

I prefer using Witch, as it has lots of options, allowing you to use a switcher more like Windows one, making no distinction between windows and apps, or use it the way I do, which is to use it as an improvement to OS X default way of switching between windows inside an application. BTW I use Alt+Cmd+Tab as this shortcut, and doesn’t conflict with any other shortcut, working all the time.

Windows Snap

When working with many windows, sometimes is useful to be able to “snap” windows to one side of the screen or the other. This feature is really useful on Windows (starting from 7), but I’ve been missing it on OS X since the beginning. Also, maximizing not always maximizes in both directions, but only in vertical (depends on the application). Finally, on OS X “El Capitan”, maximize button has changed to fullscreen as the default option, having to press Alt to maximize. This version of OS X also includes a feature like Snap, but only works for fullscreen apps.

So, recently I found a way of overcoming this and having nice shortcuts “a-la-Windows”: Spectacle. This nice app sits in your menu bar and helps you to quickly resize your windows (snap, fullscreen, even quarter of screen snap), move them between screens, even undo and redo this actions!

Switching to Firefox again

The other day I stumbled upon the article Windows Timer Resolution: Megawatts Wasted and to make long story short, I ran powercfg -energy duration 5 on my system and found that Chrome, Spotify and Naver’s Line client for Windows were making my system to increase timer resolution to 1 ms, wasting energy and making my laptop run warmer than expected.

So I’ll be switching back to Firefox after quite a while using Chrome as my main browser, at least for regular browsing. Let’s hope Google fixes this soon.

Also, I’ve switched to Windows Store App version of Line client (my system runs Windows 8.1), and I’m considering what to do with Spotify.

UPDATE: maybe I’ve switched browsers too fast: now I’m seeing Firefox also increasing timer resolution to 1 ms! Possible causes:

  • Plugins (Flash, maybe?)
  • Google Mail
  • donno…

I’ll keep you posted.