Android Development for iOS Developers

Android development has greatly improved since the early days. Maybe you tried it out when Android development was done in Eclipse, emulators were slow and buggy, and Java was the required language. Things have changed a lot since then, and those days are long gone. Android Studio is now the official IDE, Kotlin is growing in popularity and will seem instantly familiar to a Swift developer, and the emulators are actually quite good including features that the iOS simulators don’t even try to support (biometric authentication anyone?).

One of the big hurdles with getting into Android development can be the overwhelming amount of information to dig through. There’s a lot of history to sift through and a lot of Stack Overflow posts that are no longer relevant or are just plain incorrect. Here I’ll try to provide some helpful resources and some tips to hopefully make it easier to get started and jump into Android development if you come from an iOS background. If you’d like to skip the tips, the list of resources are linked at the end of the post.

When you first open Android Studio and start to get a test project up and running, you’ll probably be asked to choose a minimum version number you’ll support. Android Studio kindly provides a version distribution guide to help you select your minimum version. The API version numbers vs the Android version numbers can quickly get confusing, but here’s a helpful chart and additional documentation to help you navigate the versions. The version guide hasn’t been updated since May 2019 but Project Treble is improving system updates. The last few projects I’ve worked on we’ve used a minSdkVersion of 21.

You’ll also notice a section of your project called “Gradle Scripts” which contains a build.gradle file which is where you’ll manage your dependencies (similar to CocoaPods or Carthage but as a first class citizen in Android Studio). Don’t be afraid to use well supported frameworks such as dependency injection frameworks or networking frameworks. Google recommends a few such as Dagger2 (others prefer Koin), Retrofit, etc. (see Fetch Data). Be careful when adding dependencies to your gradle file. When you’re scouring the internet for help with building your app, you might see examples that suggest adding something like this to your gradle file’s dependencies section:

  1. implementation ''

Unfortunately, you’ll see this a lot and it’s not exactly what you want. Whenever possible, you’ll want to favor androidx over the older support library, e.g.

  1. implementation 'androidx.recyclerview:recyclerview:1.1.0'

This allows you to use newer APIs with backwards compatibility support. The support library is being deprecated in favor of androidx in order to make these libraries more lean and maintainable.

Now that we have project set-up behind us, let’s get to the fun part which is choosing your app architecture and building your app! When creating a new project in Android Studio, you’re given the option to start with a “Fragment + ViewModel” option which can be a good default for a lot of apps and this template follows Google’s architectual recommendations. I’d definitely encourage reading Google’s “Guide to app architecture”. Don’t be afraid to utilize Fragments, LiveData, ViewModels, and Navigation Graphs. You get a lot of benefits from Google’s recommended architecture so avoid straying too far from their suggestions unless you have good reason to.

Finally, let’s talk about Kotlin and layout files. It’s a great language and if you’re familiar with Swift, you’ll quickly start to feel at home using Kotlin after reading through the “Getting Started” Kotlin guide. However, some things won’t be immediately obvious and you’ll have a lot of Swift habits you’ll try to find analogues for in Kotlin that just aren’t there (👋 bye bye guard statements 😢 ). The first thing you’ll probably be looking to do is unwrap nullable properties with an if let statement. One way you can do this in kotlin is by using the let closure:

  1. val fruits: List? = null
  2. fruits?.let {
  3.     print("There's fruit!")
  4. } ?: print("We're out of fruit...")

If you need something like a struct from Swift, check out data classes:

  1. data class User(val name: String, val age: Int)

Do you want an enum with extra functions and initializers? Maybe skip over Kotlin’s enum and take a look at sealed classes:

  1. sealed class Expr
  2. data class Const(val number: Double) : Expr()
  3. data class Sum(val e1: Expr, val e2: Expr) : Expr()
  4. object NotANumber : Expr()

Do you want to make a class a singleton? Check out companion objects:

  1. class MyClass {
  2.     companion object Factory {
  3.         fun create(): MyClass = MyClass()
  4.     }
  5. }

Are you looking for protocols but not finding them? Check out interfaces:

  1. interface MyInterface {
  2.     fun bar()
  3.     fun foo() {
  4.       // optional body
  5.     }
  6. }

Lastly, I want to touch on layout files. Layout files are XML representations of your UI that you can string together in a Navigation Graph (the Android equivalent to Storyboards). What’s great about Android layout files is that you can manipulate the XML directly without using the layout builder. I recommend tapping the “Text” tab in the lower left-hand corner when viewing a layout file so you can see the XML and the preview next to each other.

Android Studio Layout suggestion

There are many layout types that you can leverage such as LinearLayout or RelativeLayout. More recently, Android has introduced something that will be familiar to AutoLayout users called ConstraintLayout. It’s okay to use any of these and mix and match them for your use case. Sometimes LinearLayout does everything you need without the overhead of maintaining the constraints in a ConstraintLayout. If you dive into ConstraintLayout, you’ll probably find out fairly quickly there aren’t inequality constraints. However, you can achieve something similar using chains.

I hope this filled in some holes that reading through tons of documentation can leave when starting something new. I’ve linked all of the resources from the post below as well as some others I’ve found helpful. Good luck and happy coding!

Helpful Resources

About the Author

Object Partners profile.

One thought on “Android Development for iOS Developers

  1. Chee Yi Ong says:

    This is a great read, Brian! Thanks for sharing.

Leave a Reply to Chee Yi Ong Cancel reply

Your email address will not be published.

Related Blog Posts
Natively Compiled Java on Google App Engine
Google App Engine is a platform-as-a-service product that is marketed as a way to get your applications into the cloud without necessarily knowing all of the infrastructure bits and pieces to do so. Google App […]
Building Better Data Visualization Experiences: Part 2 of 2
If you don't have a Ph.D. in data science, the raw data might be difficult to comprehend. This is where data visualization comes in.
Unleashing Feature Flags onto Kafka Consumers
Feature flags are a tool to strategically enable or disable functionality at runtime. They are often used to drive different user experiences but can also be useful in real-time data systems. In this post, we’ll […]
A security model for developers
Software security is more important than ever, but developing secure applications is more confusing than ever. TLS, mTLS, RBAC, SAML, OAUTH, OWASP, GDPR, SASL, RSA, JWT, cookie, attack vector, DDoS, firewall, VPN, security groups, exploit, […]