In the past 6 months, my Android development environment has changed quite a lot. If you follow me on Google+ and/or Twitter, you may have noticed these changes reading some of my latest tips. I love talking about UI and performance but I also seriously consider tools are crucial entities in the process of developing nice and polished Android apps. In this post, I share about my experience and the tools I use everyday when coding:
- A blazingly fast virtual device: Genymotion
- A powerful IDE: Android Studio
- An evolved build system: Gradle
Developing awesome apps requires energy, passion and commitment. But I also believe great applications come from great development environment. Indeed, I have always thought applications are images of the tools developers are using. Fast emulator involves faster testing which, in turn, involves more polished applications. In the same way, intuitive and user-friendly development tools initiate/inculcate developers with a sense of UI/UX design they can reflect in their products.
Put simply, I am convinced the quality of the dev tools we are using are a direct consequence of the quality of the apps we are creating (and vice-versa). I have always been disappointed about how rustic and raw concrete Android dev tools were but it appears Google is now making a clear turn towards polished and productive dev tools. In addition to that, I am thrilled to see some companies such as Genymobile help the entire ecosystem to move in this direction.
The name of Genymotion is probably completely unknown to you. But I assure you this won’t be the case for so long. You will quickly learn to remember its name once you will try it out. In a nutshell, Genymotion is a feature-complete replacement for the default Android emulator (which has became un-usable due to its serious lack of performance with the latest versions of Android) that can be downloaded on the Genymotion website. The solution is based on Virtual Box and hence consists on virtualizing an Android device rather than emulating it.
I don’t consider myself as a virtualization/emulation expert but it looks like emulation is not an option anymore. As of today, the iOS SDK offers a simulator (apps are compiled to target the host architecture) and the latest Windows Phone SDK is bundled with a Windows Phone Emulator which is actually a virtual machine. I have the feeling virtualization is the best solution to solve both the performance issues inherent to emulators and the “binaries differences” simulators suffer from.
If you have already tried Genymotion, you already know the key difference between the default emulator, an hardware device and Genymotion: speed! Genymotion is extremely fast and makes Android development a pleasure. Genymotion relieves you from the burden of switching from your work station to your hardware device for testing. Thanks to this amazing piece of software, everything happens on your own work station.
In order to demonstrate how speedy Genymotion is, I ran a small project of mine with a few instrumentation tests on both my hardware device (a Nexus 4) and an instance of Genymotion running on my MacBook Pro. The outputs are just self-explanatory, running the instrumentation tests on Genymotion is at least 10 times faster than on a Nexus 4:
I first tried Genymotion when it was still known under the name of AndroVM. At that time, the product was clearly a tool with a great potential. But its lack of polish and its hard setup was making it a no-go in most Android development environments. The latest version of the software clearly demonstrates Genymobile (the company behind Genymotion) decided to push Genymotion to the next level.
After a nice new demo by the Genymotion team at Droidcon France, I gave it another try and after a single hour playing with it and testing it, I decided to start using it everyday when developing. Thanks to Genymotion, my personal hardware device is now almost only necessary for real-life/final development phase testing.
Speed is one of the most important aspect of Genymotion. However, it also offers some other nice features:
- Tested & trusted ROMs: The team is working hard on ensuring Genymotion ROMs are CTS-compliant. They recently announced Genymotion already passes 99.4% of the AOSP CTS. We can expect the ROMs to be fully compliant with the CTS soon.
- Hardware management: You can already emulate a lot of things in a very cool way. One of my favorite option is the GPS sensor management. You only need to move a marker on a map and Genymotion forwards the appropriate GPS fix. This is insanely handy when developing location-based apps.
- Google Play Services support: Some ROMs being bundled with the Google apps, you have access to the exact same features a real device has. Thus, you can install and test frameworks such as Google Play Services. This lets you test your apps even if they are using Google Maps Android API v2 or the latest location APIs (fused location provider).
- Full integration with Android Studio & Eclipse: Genymotion presents a simple UI to start/create new virtual devices in a blink of an eye. If you are not fond of this small piece of software you can alternatively use the Eclipse or the Android Studio / IntelliJ plugins.
- Platform independent: Just like you can develop Android application on Windows, Mac OS X or Linux, Genymotion comes with several flavors: one for each platform/architecture.
- Shell-capable: Genymotion provides a tiny shell enabling you to script some modifications of sensor states.
Let’s be clear, having a fast virtual device doesn’t mean you don’t have to test on real device. It is a good opportunity to prototype and polish your applications in a fast manner. However, real devices are still the best way to ensure everything runs smoothly in real life.
Genymotion still suffers from some minor bugs/missing features and from what I consider a disappointing UI1 (it’s still a beta after all). But its amazing fastness, true potential and ease of integration to the development environment makes it an obvious choice in your development toolkit. I personally know some of the guys in the Genymotion team and I am confident about the future of the software. They work hard on improving a tool that is probably the biggest step forward in Android emulation/virtualization/simulation since Android has been revealed in 2008.
About 5 years ago, I started developing my first Android app: a school project. At that time, the framework was only available as an early look and I chose Eclipse as my main IDE for two main reasons:
- Eclipse was the required IDE for computer science classes
- Eclipse was the only IDE bundled with an Android plugin
About 6 months ago, I switched to IntelliJ and more recently (since Google I/O 2013) to Android Studio. The reason behind the switch is pretty logical. Indeed, Eclipse was starting to be a pain in the ass for most of my projects. It was mainly too slow and was crashing often. After almost 5 years using Eclipse, switching to IntelliJ/Android Studio was not easy but it wasn’t painful either. The learning curve is quite impressive: it only took me an entire week to get used to the new shortcuts, the new look/appearance and some of the main features of the IDE.
In addition to being fast and stable, Android Studio has several advantages over Eclipse you can discover either by downloading and playing with the software or by watching the Google I/O keynote and the “What’s new in Android development tools” session Tor Norbye & Xavier Ducrohet did.
At the time of the writing Android Studio is an “I/O preview” and in version 0.1.6. The version number may not refer to a final version, Android Studio relies on the shoulders of a giant. If you are not fond of Eclipse and are looking for something new, you should definitely give Android Studio a try.
Gradle build system
At Google I/O, I wanted to learn about all the new improvements related to the Android development tools. I obviously attended all of the talks related to the new Gradle-based build system. Even though the Gradle plugin is still in a development phase (0.4.3 at the time of the writing), I already strongly encourage people to use it in their projects.
I recently switched all of my projects to the Gradle plugin. The main reason behind that is the new build system finally deals with all of the features an Android developer may need. Moreover, Android Studio works best with Gradle. Here again, the plugin is not perfect of course but I am sure the Android tools team is working hard on polishing this new build system.
Here are some of the features I appreciate the most:
- Package renaming: This is particularly useful if you want to have both the debug and release versions (and more?) of your application on the same device at the same time.
- Powerful dependencies management: While this is clearly not new to Maven users, it is a huge leap forward for developers using the current Ant-based build system.
- Integration & development similar builds: The new build system has been designed so that the builds executed on the continuous integration server are similar to the ones built by developers on their work stations.
- Easy and sharable signing configuration: The new plugin shares project signing configurations. This is extremely useful if you want the debug key to be used by all of the developers in your team2.
- Product flavors: Flavors are particular version of your application that can have a different package name, version name/code, etc. This is mostly useful when you need several APK outputs: a free and a paid APK.
If you want to send feedback, report bugs, ask for help, etc. I encourage you to go to the adt-dev Google group. Chances are high, some people like Xavier Ducrohet (a Google engineer on the Android tools team) will help you (in case you post complete and precise questions of course). Here are some important links that helped me to switch to the new Gradle-based build system:
- What is new in the latest version of the new build system: http://tools.android.com/tech-docs/new-build-system
- The new Android SDK build system Google IO session
- New build system documentation: http://tools.android.com/tech-docs/new-build-system/user-guide
- Gradle Wrapper documentation (recommended by Google): http://www.gradle.org/docs/current/userguide/gradle_wrapper.html
- A zip containing tons of very interesting examples: http://tools.android.com/tech-docs/new-build-system/gradle-samples-0.4.2.zip
All of the tools described in this post make the Android development environment more efficient and productive than ever. They all are works in progress but they already demonstrate Android has a bright future ahead of itself. New Google-powered tools such as Android Studio and the new Gradle build system in addition to the insanely powerful Genymobile’s Genymotion are excellent initiatives to future-proof Android development tools.
If you are still thinking about what to do, here is my piece of advice for you. Do not hesitate, stop thinking, revolutionize your Android development environment right now by switching to these new awesome tools and help them to be even better than they already are.
While being understandable and self-explanatory, I seriously think Genymotion’s UI could be way simpler. The product is already awesome from a functional/feature point of view. Reducing friction due to the current ineffective UI would make the product truly revolutionary and ground-breaking.
Some APIs and/or frameworks such as Google Maps Android API v2 require an API key based on the key used to sign the APK. Sharing keys between developers at the project level, may relieve you from the burden of managing several API keys.