Hello Kotlin & Composable - Goodbye Java & XML Layouts

Android developer's log, Stardate 2023.1: 👽

it all started with an email from Google Play regarding various clarifications to their Target API Level Policy and how apps that fail to comply new requirements will experience "reduced distribution" on the market... 👀 ....well.......

Oh... I get it - it's one of those emails that makes you do stuff.... well f*** me.. 😅

Let me walk you through this: the above mentioned Google Play's Target API Level Policy states the following:

  1. New apps and app updates MUST target an Android API level within one year of the latest major Android version release. New apps and app updates that fail to meet this requirement will be prevented from app submission in Play Console.
  2. Existing Google Play apps that are not updated and that do not target an API level within two years of the latest major Android version release, will not be available to new users with devices running newer versions of Android OS. Users who have previously installed the app from Google Play will continue to be able to discover, re-install, and use the app on any Android OS version that the app supports.

New apps can't target older API versions & you also need to update your app frequently or it won't be offered to the users running newer Android version on their devices.

Sounds kinda strict to me.. 🤔 but I guess that guys @Google had their reasons for making such an inflexible policy.
Anyway, here are my impressions after finishing the latest major update for my app.

Step 1: Java to Kotlin

Kotlin was introduced in 2011 by guys @JetBrains but it wasn't until 2019 when it became an official language for Android development. Naturally, this was my 1st step along the way and I really loved it. Although I do like good ol' statically typed OOP, I was never a big fan of Java, especially after Oracle took over. Somehow it went from "Come to the dark side - it has GC & it works on every platform" to "We publish major release every 6 months so yeeeah - feel free to go f*** yourself". I guess they can stop using coffee mug as Java's logo & switch directly to methamphetamine, cause coffee just won't cut it anymore.
Furthermore, you can tell the language sucks big time when the guys using it 24/7 don't wanna play with it anymore and need to find/make themselves an alternative. And that's why Kotlin fits like a glove - it reminds me a lot of TypeScript, so it made a whole process a lot easier - thank you sexy brainiacs from JetBrains... 🧠💗

Step 2: @Composable

Now let me tell you something about Jetpack Compose - this s*** is lit... 🙌
At first, it was like XML layout never existed & got replaced overnight with this brand new Compose thing. Forget about resource layouts, cause UI is now being defined directly within your Kotlin code using composable functions. Alignment & arrangement are done similar to flex in CSS, so it wasn't very hard to pick up - actually, I've enjoyed it, especially using built-in modifiers to customize almost every aspect of your composable element.

Step 3: "SharedPreferences" vs "DataStore"

Ok, this is where I got myself in a pickle.. 🤔🥒
Back in the days we had something called "SharedPreferences" - an interface for accessing & modifying user preference data. This key-value pair concept has been used since the start of Android development. It had its flaws, but it really wasn't that hard to master or implement, e.g.:
  • it doesn't provide type safety
  • it's not safe to call from UI thread
  • can't signal any error
  • can't handle data migrations
Those cons gave birth to new & improved data storage solution aimed at replacing SharedPreferences - the DataStore. It was built on Kotlin coroutines and Flow and it stored data asynchronously, consistently and transactionally.
It's all well and good but the problem with DataStore is that this thing is, pardon my French: hard AF to implement. 😑 I must've lost hours before getting it to work properly - and I blame this on Google. You don't just implement such a major update without providing enough relevant documentation with plenty of examples - and I mean like really SIMPLE examples. It's not enough to publish an 8 min long tutorial with an incomprehensible codelab - fancy animation & friendly host just won't do the trick:

Don't believe me? Just check out the comments...

......or maybe it's just me & I'm getting dumber with age. 🙄 Again, this one's on Google, cause their job as Android SDK devs is to make things straightforward & more approachable. Android development should get easier with time, not the other way around. Just ask yourselves - maybe if your milestones were more clear & organized - you wouldn't end up with such drastic cuts in the first place.

Step 4: Publishing

Now, this one went as smooth as a baby's bottom 👏
I also like what they did with testing in Play Console: you can now put your APK/AAB to the test (internal, closed or open) before publishing it.


Well, it surely took me more blood, sweat & tears than I've originally expected, BUT let's face it - learning new stuff is always gonna be time-consuming. Also, Google guys need to understand a few basic concepts like: less is more & not all of us are willing to sacrifice 8 hours a day trying to figure out some brainiac sh** you're all so proud of - don't forget what your job is all about.