Add your SDK
Home / Java
Enjoy the best mobile SDKs news, tips & tricks, sent to you by mail

Hello, Kotlin! How to Convert an Android Project – Part 1

January 17, 2017 5:13 PM

I’ve been hearing about Kotlin everywhere. It’s the new big thing in the Android world. So big that Gradle themselves are talking about incorporating it.

So I set out on a journey to see what the hype is all about.

What is Kotlin? Well, simply put it’s a statically-typed language from the house of JetBrains that compiles to Java’s bytecode and therefore can be run using a JVM. It’s got lots of interesting features and full compatibility with Java.

The following post is not a conventional Hello World tutorial on Kotlin, rather it’s an experiment with a big bold “don’t try this at home” warning. It’s risky and code might break because I’m going to convert a whole project of a mid-level complexity (30 classes) at the click of a button, or rather 4 buttons (ctrl + alt + shift + k). If that won’t work out (spoiler alert: it didn’t), I’ll switch to plan B and convert my project one class at a time.  I’ve decided to see if they’re making good on their promise, as well as teaching myself a new programming language upside down. From big concepts to the finer details.

Because I’m going to mess with lots of code and it might not end up pretty I chose to convert one of Android’s google-samples projects which I forked. I chose the todo-mvp branch: https://github.com/SerjSmor/android-architecture. If you are unfamiliar with different styles of Android architecture (MVC, MVP, MVW) or their implications I highly recommend going over them anyway if you haven’t yet.

TL;DR: we’re converting a TODO List app.

Environment:

IDE = Android Studio 2.1.2. There’s a plugin for Eclipse too.

Kotlin version = 1.0.4

The before photo (before tinkering):

Hello, Kotlin! How to Convert an Android Project – Part 1

Continue Reading

The Hitchhiker’s Guide to StackOverflow

February 22, 2016 3:28 PM

A little less than a year ago, it finally happened to me too. I stumbled upon a question that even Dr. Google couldn’t answer. No search result seemed to fit. So after years of standing on the sidelines, I signed up to StackOverflow. What’s StackOverflow? Well, for those of you who are new here on Earth, it’s a brilliant question and answer site for programmers.

So I asked my question. And then, armed with my very own StackOverflow profile, I figured the next step should be to give a little back. After all, the community has always been there for me. Why not do the same for them?

So I did. And man, ho man, the things I’ve learned once I crossed the threshold.  Two things in particular surprised me the most: The first was the engagement. Every answer I gave was almost immediately followed by additional people commenting and relating to my answer; the second was the fact that so many people worldwide got completely chastised, immediately after posting their first question ever. Their questions were muted or deleted, and their entire first step in the big vast stack exchange universe left them with a bad aftertaste.

In fact, ‘newbies’ common mistakes inspired me to write down my thoughts, talk about these little pitfalls that have surely frustrated anyone who’s been hanging around the StackOverflow watercooler long enough.

So allow me to share with you some of the things I’ve seen, once past the velvet ropes.

Continue Reading

The Holy Gradle: Setting Up Your Android Build on a Build Server – Part 2

July 15, 2015 8:11 AM

In my previous post I went over some basic terms used by Gradle and the Android build system, and over the flow of the build. With these understandings at hand, we are now ready to go over concrete steps and set up our build server, without Android Studio, or in fact without any GUI tools at all.

For the sake of this post I will assume you are setting up your new build environment on a Linux server, and you don’t have the Linux GUI at your service, only the command line. Of course, it can all be set up on a Windows or Mac machine just as well.

Let’s also assume that your user on the build machine is called “user”, and therefore your typical home directory would be /home/user.

Now let’s go step by step:

1. Download and install the JDK

First download the JDK you work with. I have downloaded JDK7 from Oracle’s site. If your Linux environment doesn’t support rpm – you will need to download the tar.gz version and extract it, for example to /home/user/.

2. Download and install Gradle

You can download Gradle’s latest release from here. The binary distribution will do, no need for the complete distribution. I chose to use Gradle 2.4.

By the way, There is the option of avoiding the explicit installation of Gradle if you are using the Gradle Wrapper, but let’s leave this topic aside. Personally I think that if you are setting up your build server, the better approach is to explicitly download the Gradle version you want. Once downloaded, extract the zip file, for example under /home/user.

Continue Reading