by Aakarshit Uppal
How to develop an Android App in 2019: embracing the ‘new’ Android
or how the Bitotsav ’19 app became a reality
Background: Pantheon ’17 ⏪
Almost two years ago, in September 2017, a friend, Ashank Anshuman convinced me to work on an app for the technical fest of our institute. We worked for about two weeks, day and night, getting it ready for release just in time for the fest. Although we were exhausted, it was an amazing feeling, getting something ‘out there’, in production, that people actually used! It served its purpose perfectly well, helping the organizers easily convey everything to the participants.
It was rated 4.9 with around 120 reviews, which Google’s bots removed for some reason, but that’s a story for another time. We received some requests to share the source of the app, but we declined, due to many reasons — but mostly because we weren’t that satisfied with the code, especially the parts rushed through near the end. We simply didn’t have enough time and experience to write code good enough for people to learn from and/or use.
Here We Go Again! 🙃
Fast forward to November 2018: Ankit Agrawal (he’s that ‘fest guy’) asks me to join the team for Bitotsav, our annual socio-cultural fest, to which I agree, as I was looking for some excuse to revisit Android. This time I convinced Ashank (took a lot of convincing!) to work on the app.
We didn’t do much in December, but I did start reading on things like Architecture Components, AndroidX, Jetpack etc. I had also been getting familiar with Kotlin over the past few months, with a couple courses being instrumental: A two-part course by the one and only Hadi Hariri and another more recent one by Svetlana Isakova and Andrey Breslav (which he introduced in KotlinConf 2018). Kotlin was thus the obvious choice for the app.
Introduction to Kotlin Programming
Kotlin 1.0 was released in February 2016, and since that time it's been embraced by developers around the world…shop.oreilly.coKotlin for Java Developers | Coursera
Kotlin for Java Developers from JetBrains. The Kotlin programming language is a modern language that gives you more…www.coursera.org
The first half of January also went by with not much code being written, as I was preoccupied and couldn’t reach the college till 16th Jan. We did, however, make some major decisions:
- Use Kotlin exclusively
- Use Feature-based packaging
- Use Jetpack Architecture Components with AndroidX
- Use API 21 as Min API (22 might’ve been a better choice)
- Use Android Studio Canary
- Use Git Flow & SemVer
- Write code good enough to make it public after the fest 🙈
So basically, a hard reset from all the experience of developing an app in 2017 to the bleeding edge in 2019. It was really exciting, but also a big challenge.
Code Code Code! 💻
We decided that Ashank would take care of the Backend of the app (DB & Networking, Notifications with FCM, Background Processing) and I’d take care of the Frontend and Integration, just like we did for Pantheon ’17. Many resources came in handy while getting started and as we worked, but the best by far were these awesome codelabs offered by Google:
- Room with a View - Kotlin (ViewModel, LiveData & Room with Coroutines)
- Using Kotlin Coroutines in your Android App
- Data Binding Codelab
- Navigation Codelab: (Navigation Architecture Component)
- Background Work with WorkManager
Also, the Sunflower & Google IO 18 apps by Google were ideal codebases for the purpose of reference. Android Dev Summit app would also have been a good source for reference, had I known about it before!
With these in our arsenal, we began coding. I decided to use the new Navigation architecture component to implement a single-Activity app architecture. Ashank started with Room and FCM. I had also been thinking about using Koin for IoC, but wasn’t so sure.
Incidentally, Joe Birch launched a Koin course right around that time on caster.io (Features small, to the point courses by professionals, each free for a week on launch!), and decided to go with it. No regrets there! Seriously, the android support is amazing and the documentation is fabulous ❤️
With Navigation and Koin setup, I began with the UI, deciding was to use material design components exclusively for UI for which the guidelines and docs came in handy. Also, I had to use Data Binding because I love it! Meanwhile Ashank implemented WorkManager, which we decided to use instead of Firebase Job Dispatcher, going full Jetpack!
The first thing I developed was the Schedule UI, which helped me get comfortable with Architecture Components. With that done, I moved on to the Registration-flow UI, probably the most complex part of the app, which featured advanced usage of LiveData and Navigation for implementing three steps with live-validated forms (Worth a blog post of its own, coming soon?!). This made me a lot more confident in these components, and it was a smooth ride from there on. We completed the planned features, discovered some gotchas, fixed some bugs.
With major features implemented, we did some UI brush-ups, completed some final TODOs, and were ready for launch! As a finishing touch, I added something I had been planning for all along:
A different color theme on every configuration change! This was done to compliment the theme of the fest: “Colours of Asia”
The app was live on the Play Store on Feb 11, 2019! 🎉🎉
Fixes & Updates
We faced (the only!) two bugs within hours, which we fixed right away. The first one was related to DAO methods being marked
suspend, but I’m still not a 100% sure why exactly it was happening 😅. The second one was caused by obfuscation causing a serialization failure, and was easily fixed with a Keep annotation.
Then I started working on the next update, in which I added the leaderboard in the feed and the night events for the fest in the schedule, along with some other changes. A third update followed adding some more minor features.
The fest went well, and the app was used by over 1000 participants!
We did face a minor issue due to an incorrect DB entry in the servers by our friend Sushant Gupta, who later proceeded to write a rather dramatic blog post on the same.
After the fest, we released a final update, storing the event details, feed etc. as JSONs as part of the app and redacting the contact numbers of the organizers for privacy reasons.
It was time to open source the code! This time around, we had taken care to write understandable code, and it was ready for the world. I prepared a slick README, and to remove the contact numbers from the history of the repository, we used the amazing BFG Repo Cleaner tool.
The code for the Bitotsav ’19 app is now public, for anyone to review, refer to, learn from or use! Check it out and don’t forget to leave a 🌟 😄
We did face some challenges during the development:
- Time Limitations: The main challenge we faced was of having a very limited time to learn very new concepts and use them to create an app to be used by hundreds. This time constraint led to a lot of continuous hours being put in, leading to stress and fatigue, but we were able to power through and deliver!
- WorkManager with Coroutines: On the technical side of things, we faced some minor challenges with WorkManager and Coroutines, but were able to overcome them. Hoping for a better support for coroutines throughout the Android SDK as development continues 🤞.
- API 21: We chose min API 21 to avoid having to adapt everything to work on older versions, as most android devices are on API 21 and above anyway. But surprisingly, some things refused to work on API 21, especially view backgrounds. It was really frustrating, making me wish we had set min API as 22, even more so when we found out that the app had been installed only on two API 21 devices: the ones we had tested on 😿.
- Lack of Devices: Another challenge we faced was not having enough devices to test on. During Pantheon ’17, we had a hostel with ~200 people, and thus testing was easy. This time around most people were gone for internships, so we were left with relying on having confidence in the code!
- No code reviewers: A lot of what we used was new to us, and we did our best to ensure we were doing everything right. But having a reviewer would have been very helpful. Even now, if you feel like you could do a quick review of the app’s code, we’d be very thankful!
- The Apocalypse: We did also face that ‘ DDoS ’ issue, read Sushant’s blog post linked above, you won’t regret it!
- Kotlin + Jetpack = ❤️ : The main takeaway was that Android Development has come a long way and with Kotlin and Jetpack, it’s definitely a lot more fun and purely joyful! Seriously, there were multiple orgasmic moments during the coding process!
- Nothing is Impossible: Kinda cliché but true: if you have the will to work hard, you can do anything, no matter how difficult. Sure, there will be stressful phases, but keep powering through. Just believe in yourself!
- No Instant App / App Bundles: We just straight up missed this one. Didn’t even think about it. Ah well, maybe next time.
- No tests: I know, this is a big one! Having proper tests in place could have helped us a lot, but due to the time constraints, we decided not to write tests until a ‘later’ time, which hasn’t yet come 🙈.
Starting with an app with 2019?
Use Kotlin & Coroutines
Use Jetpack Components with AndroidX
- Learn to use Navigation Component for Single-Activity Architecture.
- Learn to use Lifecycle Components for UI & Room for persistence.
- Do yourself a favor and use Data Binding!
- Learn to use WorkManager for background processing.
Use Material Components
Well we couldn’t but you definitely should! Do NOT skip tests.
Refer to Source Code
Stay up to date
Subscribe to blogs and newsletters to stay up to date! Here are some to start with: Android Weekly, ProAndroidDev, AndroidPub, Kotlin Weekly. Overwhelmed? Check out this awesome talk by Huyen Tue Dao:
Well, there we go. This is a great time for Android Development, so go get started with your new app, and don’t forget to have fun while doing it!
👏 if you learned something, constructive criticism welcome 😄
Until next time 👋👋