Tech

Towards a seamless experience in Android Development – Mobile, Wear, Things & Automotive

By Claudiu Groza
Mobile Software Engineer
LASTING Software
(Presentation held during Codecamp Timisoara, April 2018)

Seamless is a software development goal that became a standard. The Merriam-Webster Dictionary defines it as “having no awkward transitions, interruptions, or indications of disparity”. It makes sense. Any programmer aims for a seamless final product. Moreover, having a seamless development experience guarantees reaching this goal.

As for Android, as we know, it “is an open source, Linux-based software stack created for a wide array of devices and form factors”.

But what does a seamless development in Android imply?


We will approach the development benchmarks, as listed below:

▸ Platform Architecture

▸ The Android Base Components

▸ Design and Build Performance

▸ Google and Community Libraries

▸ Kotlin

▸ Android Automotive: the yet missing part


1. Platform Architecture

▸ I have compiled the major components of the Android platform per types of development.

For Mobile, Wear and TV development, we have:

For Things development, you may notice the differences:

As for Automotive, the specifics are underlined in this figure:

The platform dependencies are as follows:


2. The Android Base Components


We may look at the base components as if they were building blocks. I detailed each one of in the following:

  • Activity

▸ Wear – adds support for Ambient mode: WearActivity or Ambient Support Mode

▸ Things – activity’s graphical user interface is optional

▸ Things – home activity is automatically launched on boot (single app execution)

▸ *Automotive – activities may require to support “Split Screen” feature

  • Services

▸ API 26 introduces background service limitations

▸ Use service.startForeground() for long running foreground services

▸ Use JobIntentService as a wrapper for JobService API

 

  • Broadcast Receiver

API 26 introduces more stringent broadcast limitations

▸ forbidden to register for implicit intents via the manifest

▸ Registration for implicit intents must be executed at runtime by using Context.registerReceiver()

▸ Registration for explicit intents remains unchanged (manifest or runtime)

 

  • Content Providers

▸ Third party apps tend to narrow access to their content providers

▸ System apps (for example, Contacts) will still share content via content providers

▸ Things – removed support for essential content providers

 

  • Intent

▸the binding component for all of the above


3. Design and Build Performance

The highlights here would be:

  • Design comes first:

▸ Back in the recent past, Android development was governed by “always design for performance”

▸ With the current level of codebase complexity, software architecture activities became more and more important

▸ The community was the one to start evangelizing patterns to organize code

▸ Apply micro-optimizations judiciously respecting the effort implied

 

  • Gradle

▸ Master Gradle to speed up your build time and limit dependencies

▸ Strive to organize the application’s modules/components as Gradle modules

▸ Break down modules to take advantage of the incremental build feature

 

  • Multi-context app showcase:



4. Google and Community Libraries

Support libraries are Google’s approach for solving platform dependencies, fragmentation issues, and independent deployment.

▸ Platform support libraries provide extension packages for Wear, TV, Things, Automotive

▸ UI support libraries move the burden from developers to implement specifics based on platform versions

▸ Architecture Components libraries solve head-scratching issues of Android development: activity lifecycle, persistence access etc.

 

Community libraries provide a large share of reusable components used in Android development

▸ RxJava, RxAndroid, Dagger, Retrofit, OkHttp, Butterknife

▸ Successful community libraries are forked and maintained by the Google dev team

▸ Google’s Architecture Components offer support integration with community libraries like RxJava (Room Library use case)


5. Kotlin

Kotlin is “an OSS statically typed programming language that targets the JVM, Android, JavaScript and Native. It’s developed by JetBrains. The project started in 2010 and was open source from very early on. The first official 1.0 release was in February 2016”. (Source: Kotlin webpage)

This programming language became a first citizen at Google IO 2017. It also listed as the protagonist at Google IO 2018.

It is only natural to wonder about Java at this point. There are a few updates needed on this:

▸Google plans to sideline Java

▸ There is the legal battle with Oracle over Android’s framework Java code

▸ Kotlin <-> Java = 100% interoperable

▸ Kotlin blends in and tries to solve the specific needs of the Android framework (e.g. lateinit properties)

 

Check out the figure below to see how Android programming languages rank in 2018:

As for a Kotlin example, the “Kotlin in Action” book provides good examples of Kotlin migration and how to write idiomatic code in Android:



6. Android Automotive

Android Automotive is a standalone platform, which targets to provide In-Vehicle Infotainment.

▸ It is different from Android Auto!

▸ The development started in ~2014

▸ Audi and Volvo were the first OEMs working closely with Google

▸ Qualcomm and Intel pursue hardware development

 

Android Automotive expectations

▸ The “device” costs thousands instead of hundreds

▸ The effort will be spent to migrate existing solutions

▸ The Automotive AOSP indicates most of the progress achieved until this moment

▸ Some development roles might be reconsidered: App Developer, OEM App Developer, Android Firmware Developer

 

In conclusion, in planning a seamless Android development experience, remember these:

▸ Mobile, Wear, TV, Things and Automotive share the same core framework

▸ The community holds a decisive role in adopting and validating ideas

▸ Developers are motivated in exploring new platforms and sharing their experience

▸ Kotlin is a valuable language, as it successfully replaces Java