Don’t write Android apps like it’s 2009!

mgazar_

Mostafa Gazar

Posted on November 5, 2019

Don’t write Android apps like it’s 2009!

The following is based on my experience working on various Android apps for the past few years and seeing how the framework and the development ecosystem evolved over time.

Concurrency

  1. Avoid Async tasks, really do not use them. Kotlin coroutines (👍) or RxJava are much nicer to use.
  2. Don't use Loaders, if you don't know what they are don't bother really.
  3. Don't use bare threads or manage them on your own.

Clean Code

  1. Use a dependency injection framework, Koin is great to start with.
  2. Avoid dagger in your first project.
  3. Don't use Guice!

UI

  1. Use Jetpack Components instead of the original Android Support Libraries. And when going through old tutorials remember to replace dependencies with their andoridx.* equivalent.
  2. The recommendation now is to build single Activity applications (or small number of activities) which contradicts the old advice of having a ton of activities. JetPack navigation works great if you follow this advice.
  3. Don't use headless fragments for communicating between them within an activity. Maintain view state via ViewModels and shared ViewModels instead.
  4. ConstraintLayout is great, give it a try.
  5. Use RecyclerView instead of ListView, GridView, GridLayout, …
  6. Favor Jetpack Fragments over platform Fragments.

Push notifications

  1. GCM is deprecated, use FCM instead.
  2. Starting in Android 8.0 (API level 26), all notifications must be assigned to a channel, without a notification channel, the notification will not appear and the system logs an error.

Other

  1. Eclipse, what is that! Android Studio is great.
  2. Use Room if you need to manage your internal databases. You can use them with Kotlin coroutines as well.
  3. Use exo player for audio and video playback.
  4. Use Kotlin instead of Java and make use of what Kotlin has to offer instead of writing Java code disguised in Kotlin syntax.
  5. DownloadService is still great.
  6. Keep an eye on Compose.
💖 💪 🙅 🚩
mgazar_
Mostafa Gazar

Posted on November 5, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related