My 2cts on software architecture, digital transformation, and other concerns

The Stumble Stones

The Android Team’s switch from the Eclipse based Android Developer Tools to the IntelliJ IDEA based "Android Studio" at Google I/O is pretty well-known. But what isn’t too well-known is that they also changed the default android project directory structure as they switched their build system from ant to gradle.

Further information on the new structure and the new build system are available here: http://tools.android.com/tech-docs/new-build-system/user-guide

I decided to go with the new Gradle-based structure as I thought it was more future proof. I have to admit that I regret this badly! As I’m not too familiar with Gradle, yet, I had a pretty bad time trying to understand the customizations brought in by the gradle-android plugin. Additionally most of the information available on the net is specific to Eclipse/ Ant based projects and therefore slightly different for the new structure.

Environment Setup

  • download Android SDK

  • extract it to e.g. ~/dev/android-sdk-macosx

  • modify your .bash_profile and add export ANDROID_HOME=YOUR_ANDROID_SDK_PATH_HERE

  • create local.properties

Things of great help #not

These utilities turned out to be buggy or outdated and partly messed up the working configuration. Don’t use them!

What turned out to be really helpful, were Quality-Tools-for-Android and FEST Android by SQUARE. You should really have a look at Square’s repositories at Github as there is a lot of goodness for the new Android world lying around!

Conclusion

1. Before you try things out, go RTFM.

It might take you two weeks to read https://developer.android.com/design/index.html and https://developer.android.com/develop/index.html but don’t dare to start before this! Except if you like to start-over or rewrite your whole Application. ;)

2. Before you use a library, assure that it works with Gradle!

Questions and Answers

"What is the differences between the px, dip, dp and sp units in Android?"

  • dip = Density-independent Pixels

  • sp = Scale-independent Pixels

The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".
— Android Developer Guide

Q: IDEA tells me "Project directory not specified"

A: Probably your ".idea/gradle.xml" is messed up. See this bug report: https://code.google.com/p/android/issues/detail?id=56750 to fix it

Q: My tests fail with "!!! JUnit version 3.8 or later expected"

A: The reason for this is that the android.jar contains a version of JUnit prior to 3.8! You can fix this by opening the "Project structure" settings > your module > Dependencies and putting the "Android Platform" dependency all the way down the list.

Q: I need absolute positioning but AbsoluteLayout has been deprecated

A: Yes, there is a great post by @tbeernot describing this pain. But to the rescue there is miglayout for android!

Update 2013-10-04

In the meantime there is a migration guide and a Tips & Tricks section available on the Android Developer pages!

Update 2013-10-20

In the meantime there are a few really awesome videos available on Gradle and Android, that I’d like to share with you

Tags

  • software development
  • java
  • android
  • mobile
  • article

Updated: