# architecture-components

Published articles for architecture-components.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## ViewLifecycleLazy and other ways to avoid View memory leaks in Android Fragments

DevFeed: [ViewLifecycleLazy and other ways to avoid View memory leaks in Android Fragments](<https://devfeed.tech/articles/viewlifecyclelazy-and-other-ways-to-avoid-view-memory-leaks-in-android-fragments-25885.md>)

Original publisher: [Read original article](<https://bladecoder.medium.com/viewlifecyclelazy-and-other-ways-to-avoid-view-memory-leaks-in-android-fragments-4aa982e6e579?source=rss-54910f05af37------2>)

Author: Christophe Beyls

Published: 2022-09-28T06:12:25Z

Content type: tutorial

Language: en

Sources: [Stories by Christophe Beyls on Medium](<https://devfeed.tech/sources/stories-by-christophe-beyls-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Memory Leaks](<https://devfeed.tech/topics/memory-leaks.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [memory](<https://devfeed.tech/tags/memory.md>), [memory-leak](<https://devfeed.tech/tags/memory-leak.md>), [memory-leaks](<https://devfeed.tech/tags/memory-leaks.md>), [view-binding](<https://devfeed.tech/tags/view-binding.md>)

### AI overview

This article presents ViewLifecycleLazy, a Kotlin delegated property for Android Fragments that lazily initializes values tied to the current Fragment view lifecycle and clears them when the view hierarchy reaches the DESTROYED state. It explains how this approach helps prevent view-related memory leaks and compares it with AutoClearedValue and manual clearing in onDestroyView().

### Source excerpt

Yet another take on AutoClearedValueAre your Fragments leaking? Handling the lifecycle of Android Fragments is difficult. I already covered this topic in an article I wrote in 2017, before Google added a View-specific Lifecycle to Fragments in an attempt to solve some issues. Until now, the number one cause of memory leaks when using Fragments remains the same: not properly clearing all direct and indirect View references in onDestroyView(). Tools like Leak Canary can help detecting some of these cases. And of course, Jetpack Compose represents a big paradigm change which completely removes the need to keep View references but hey, we still have our legacy codebases to maintain! I recently came across a Medium blog post from Gabor Varadi describing an issue he encountered with a custom Kotlin delegated property he created to simplify managing view bindings in Fragments. His solution is based on a class named AutoClearedValue from the architecture components samples. The purpose of AutoClearedValue is to provide a delegate that will automatically clear a value tied to one or more Views when the Fragment View hierarchy gets destroyed, in order to avoid the aforementioned memory leaks. This is an elegant alternative to declaring a Fragment property as nullable and manually setting it to null in onDestroyView(), which can be easily forgotten. It turns out I had already come up with my own solution to do the exact same thing. And since my version is simpler and generates more optimized bytecode compared to AutoClearedValue and what Mr Varadi published, I decided to share it with you. I named this delegate ViewLifecycleLazy. Like the name implies, the delegated property value is computed lazily and the Fragment's current view lifecycle is observed in order to automatically clear the value when it moves to the DESTROYED state. https://medium.com/media/17c61e41a0f2d3e17c63e3bcf8f6376c/href This is how it's used in Fragments, for example with View Binding: class MyFragment :

## Converting your Android App to Jetpack

DevFeed: [Converting your Android App to Jetpack](<https://devfeed.tech/articles/converting-your-android-app-to-jetpack-41661.md>)

Original publisher: [Read original article](<http://mikewolfson.com/blog/2021/9/8/converting-your-android-app-tonbspjetpack>)

Author: Mike Wolfson

Published: 2021-09-08T15:44:14Z

Content type: article

Language: en

Sources: [My Big Appetite - Mike Wolfson](<https://devfeed.tech/sources/my-big-appetite-mike-wolfson.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [Library](<https://devfeed.tech/topics/library.md>), [architecture-components](<https://devfeed.tech/topics/architecture-components.md>), [Developer experience](<https://devfeed.tech/topics/developer-experience.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-framework](<https://devfeed.tech/tags/android-framework.md>), [android-jetpack](<https://devfeed.tech/tags/android-jetpack.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [better](<https://devfeed.tech/tags/better.md>), [developer-experience](<https://devfeed.tech/tags/developer-experience.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [library](<https://devfeed.tech/tags/library.md>), [version](<https://devfeed.tech/tags/version.md>), [versioning](<https://devfeed.tech/tags/versioning.md>)

### AI overview

This article explains Google's transition from the Android Support Libraries to Jetpack, also known as AndroidX. It describes Jetpack's purpose, the reasons for the namespace and versioning changes, the libraries included, and the need to migrate Android projects.

### Source excerpt

This Post was originally published to Medium on Nov 27, 2018 - 7 min read Converting your Android App to Jetpack Google has rebranded their support libraries to be named Jetpack (aka AndroidX). Developers will need to make changes to account for this. This article will explain what this means, and how to get started converting your project to use the new components. Jetpack to the future What is Jetpack? Android Jetpack is a set of libraries, tools and architectural guidance that is designed to make it easy to build Android apps. It is intended to provide common infrastructure code so the developer can focus on writing things that make an app unique. It is a large scope effort to improve developer experience and collect useful tools and frameworks into a cohesive unit. This quote from Alan Viverette (Android Framework team) is a good summary: "Jetpack is a larger-scoped effort to improve developer experience, but AndroidX forms the technical foundation. From a technical perspective, it's still the same libraries you'd have seen under Support Library and Architecture Components." Why? Why is Google going through all this trouble (and creating all this trouble for developers)? Create a consistent namespace (androidx.*) for the support libraries Support better semantic versioning for the artifacts (starting with 1.0.0). This enables them to be updated independently. Create a common umbrella to develop all support components under. It is important to mention -- this current version of AppCompat(v28.x) is the final release. The next versions of this code will use Jetpack exclusively. It is imperative that developers are aware, and make the switch early. This quote from Alan Viverette sums this up nicely: "There won't be a 29.0.0, so Android Q APIs will only be in AndroidX" What is in Jetpack? The answer: everything. Jetpack is a collection of many of the existing libraries we have been using forever (like AppCompat, Permissions, Notifications or Transitions) and the newer

## Kotlin's Flow in ViewModels: it's complicated

DevFeed: [Kotlin's Flow in ViewModels: it's complicated](<https://devfeed.tech/articles/kotlin-s-flow-in-viewmodels-it-s-complicated-25882.md>)

Original publisher: [Read original article](<https://bladecoder.medium.com/kotlins-flow-in-viewmodels-it-s-complicated-556b472e281a?source=rss-54910f05af37------2>)

Author: Christophe Beyls

Published: 2021-08-28T10:42:09Z

Content type: tutorial

Language: en

Sources: [Stories by Christophe Beyls on Medium](<https://devfeed.tech/sources/stories-by-christophe-beyls-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [background-work](<https://devfeed.tech/tags/background-work.md>), [caching](<https://devfeed.tech/tags/caching.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [flow](<https://devfeed.tech/tags/flow.md>), [google](<https://devfeed.tech/tags/google.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [livedata](<https://devfeed.tech/tags/livedata.md>), [net-conf](<https://devfeed.tech/tags/net-conf.md>), [state](<https://devfeed.tech/tags/state.md>), [ui](<https://devfeed.tech/tags/ui.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

This article explains the challenges of loading UI data in Android applications when screen lifecycles and configuration changes are involved. It outlines goals such as caching valid data, pausing background work when screens are inactive, and avoiding unnecessary interruptions during configuration changes, then discusses ViewModel and LiveData as tools for addressing them.

### Source excerpt

LiveData is still your friend Loading UI data in Android applications can be challenging. The lifecycles of the various screens need to be taken into account, as well as configuration changes leading to the destruction and recreation of Activities. The individual screens of an app constantly toggle between interactive and hidden as the user navigates further and back in an app, switches from one app to another, or the device screen gets locked or unlocked. Each component needs to play fair and only perform active work when given the ball. Configuration changes happen on various occasions: when changing the device orientation, switching the app to multi-window mode or resizing its window size, switching to dark or light mode, changing the default locale or font sizes, and more. Goals of efficiency To achieve efficient data loading in Activities and Fragments leading to the best user experience, the following should be considered: Caching: data that has been loaded successfully and is still valid should be delivered immediately and not loaded a second time. In particular, when an existing Activity or Fragment becomes visible again, or after an Activity gets recreated on configuration change; Avoiding background work: when an Activity or Fragment becomes invisible (moves from the STARTED to the STOPPED state), any ongoing loading work should be paused or canceled in order to save resources. This is especially important for endless streams of data like location updates or periodic refreshes of any kind; No work interruption during configuration changes: this is an exception to the second goal. During configuration changes, an Activity gets replaced by a new instance of it while preserving its state, so canceling ongoing work when the old instance is destroyed to immediately restart it when the new instance is created would be counter-productive. Today: ViewModel and LiveData To help developers reach these goals with code of manageable complexity, Google released the fir

## Debugging LiveData changes made easy

DevFeed: [Debugging LiveData changes made easy](<https://devfeed.tech/articles/debugging-livedata-changes-made-easy-25904.md>)

Original publisher: [Read original article](<https://chao2zhang.medium.com/debugging-livedata-changes-made-easy-d3aa16b81b41?source=rss-d19045640fe------2>)

Author: Chao Zhang

Published: 2021-04-08T21:16:44Z

Content type: tutorial

Language: en

Sources: [Stories by Chao Zhang on Medium](<https://devfeed.tech/sources/stories-by-chao-zhang-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [debugging](<https://devfeed.tech/topics/debugging.md>), [Logging](<https://devfeed.tech/topics/logging.md>), [Android Studio](<https://devfeed.tech/topics/android-studio.md>), [App](<https://devfeed.tech/topics/app.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-architecture](<https://devfeed.tech/tags/android-architecture.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [bytecode](<https://devfeed.tech/tags/bytecode.md>), [class](<https://devfeed.tech/tags/class.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [java](<https://devfeed.tech/tags/java.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [livedata](<https://devfeed.tech/tags/livedata.md>), [logging](<https://devfeed.tech/tags/logging.md>), [refactoring](<https://devfeed.tech/tags/refactoring.md>)

### AI overview

This tutorial examines the difficulties of debugging LiveData changes in larger Android applications. It compares breakpoints and logging, explains why both become less effective as observing chains grow, and identifies minimal code changes and historical state information as key requirements for a better approach.

### Source excerpt

Photo by Markus Spiske from Unsplash Have you ever got frustrated to debug LiveData changes by adding numerous log statements or breakpoints? As the core data structure of Android Architecture Components, LiveData is used widely in many apps to hold observable data. However, its debugging experience could still be a pain point after these many years. Observing LiveData changes at scale There are two traditional yet powerful methods for observing LiveData changes: Debugging and logging. When it comes to debugging, we mostly interact with our IDE and do not need to touch any code. We can simply click "Debug" or "Attach Debugger to Android Process" in Android Studio and expect the process to be paused at the preset debug breakpoints. Debugging in observers In terms of logging, we can add logging statements to our observers to know when they are called. When we rerun the app, we should be able to view those log statements through Logcat while interacting with the app. https://medium.com/media/bd34828e0230fe59c141c0e820c7436e/href Both debugging and logging are effective when we have simple LiveData observing chains. While we are iterating our app with new features and business logics, we may find it necessary to scale up our app into the recommended app architecture illustrated below. As you can tell, LiveData becomes more universally used as the data holder type across different components. In other words, LiveData observing chains merely get longer and more complex. App Architecture using LiveData When debugging our app at scale, logging might be less effective, because we do not want to change code at multiple places to debug. Alternatively, we could also build an abstract class LoggingObserver<T> : Observer<T>that adds log statements in onChanged(data: T) , and require all observers to inherit from LoggingObserver. This plausible approach is cumbersome since it requires large-scale refactoring of our app code. Using debugging may not be effective either: We need to

## Firestore Pagination in Android -- Using FirebaseUI Library 🔥

DevFeed: [Firestore Pagination in Android -- Using FirebaseUI Library 🔥](<https://devfeed.tech/articles/firestore-pagination-in-android-using-firebaseui-library-25723.md>)

Original publisher: [Read original article](<https://blog.shreyaspatil.dev/firestore-pagination-in-android-using-firebaseui-library-1d7fe1a75704/>)

Author: Shreyas Patil

Published: 2019-07-21T13:00:49Z

Content type: tutorial

Language: en

Sources: [Shreyas Patil's Blog](<https://devfeed.tech/sources/shreyas-patil-s-blog.md>)

Topics: [Firestore](<https://devfeed.tech/topics/firestore.md>), [Android](<https://devfeed.tech/topics/android.md>), [Firebase](<https://devfeed.tech/topics/firebase.md>), [Library](<https://devfeed.tech/topics/library.md>), [Android Library](<https://devfeed.tech/topics/android-library.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [code](<https://devfeed.tech/tags/code.md>), [firebase](<https://devfeed.tech/tags/firebase.md>), [firestore](<https://devfeed.tech/tags/firestore.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [implement](<https://devfeed.tech/tags/implement.md>), [library](<https://devfeed.tech/tags/library.md>), [others](<https://devfeed.tech/tags/others.md>), [recyclerview](<https://devfeed.tech/tags/recyclerview.md>)

### AI overview

A tutorial on implementing paginated Cloud Firestore data in an Android app with FirebaseUI's FirestorePagingAdapter. It explains why loading large collections at once can be inefficient and outlines project, dependency, query, paging, adapter, and error-handling setup.

### Source excerpt

Efficiently implement Cloud Firestore pagination in Android using the FirestorePagingAdapter from the FirebaseUI library.

## Testing LiveData in JUnit 4 and JUnit 5

DevFeed: [Testing LiveData in JUnit 4 and JUnit 5](<https://devfeed.tech/articles/testing-livedata-in-junit-4-and-junit-5-28675.md>)

Original publisher: [Read original article](<https://jeroenmols.com/blog/2019/01/17/livedatajunit5/>)

Author: info@jeroenmols.com (Jeroen Mols)

Published: 2019-01-17T00:00:00Z

Content type: tutorial

Language: en

Sources: [Jeroen Mols](<https://devfeed.tech/sources/jeroen-mols.md>)

Topics: [Testing](<https://devfeed.tech/topics/testing.md>), [Android](<https://devfeed.tech/topics/android.md>), [test](<https://devfeed.tech/topics/test.md>), [unit tests](<https://devfeed.tech/topics/unit-tests.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [blogs](<https://devfeed.tech/tags/blogs.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [junit](<https://devfeed.tech/tags/junit.md>), [livedata](<https://devfeed.tech/tags/livedata.md>), [testing](<https://devfeed.tech/tags/testing.md>), [unit-test](<https://devfeed.tech/tags/unit-test.md>), [unit-tests](<https://devfeed.tech/tags/unit-tests.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

A tutorial on testing Android LiveData with JUnit 4 and JUnit 5. It explains why JVM unit tests cannot use Android's main thread directly and shows how JUnit rules or JUnit 5 extensions can update LiveData synchronously on the calling thread.

### Source excerpt

Architecture components are one of the most exciting things that happened to Android in the past years. But how do you effectively go about and testing this?

## MVVM with architecture components: a step by step guideline for MVP lovers

DevFeed: [MVVM with architecture components: a step by step guideline for MVP lovers](<https://devfeed.tech/articles/mvvm-with-architecture-components-a-step-by-step-guideline-for-mvp-lovers-27206.md>)

Original publisher: [Read original article](<https://antonioleiva.com/mvvm-vs-mvp>)

Published: 2018-12-12T00:00:00Z

Content type: tutorial

Language: en

Sources: [Antonio Leiva](<https://devfeed.tech/sources/antonio-leiva.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [App](<https://devfeed.tech/topics/app.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [app-architecture](<https://devfeed.tech/tags/app-architecture.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [guide](<https://devfeed.tech/tags/guide.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [opinion](<https://devfeed.tech/tags/opinion.md>)

### AI overview

This Android article explains MVVM to readers familiar with MVP, comparing how presenters and ViewModels communicate with views. It argues that MVP remains valid, MVVM is not necessarily better, immediate refactoring is unnecessary, and Android architecture components can generally still be used with MVP.

### Source excerpt

Everything Android, Kotlin and other random topics

## Breaking The Buzzwords Barrier Part 3: ViewModel

DevFeed: [Breaking The Buzzwords Barrier Part 3: ViewModel](<https://devfeed.tech/articles/breaking-the-buzzwords-barrier-part-3-viewmodel-22793.md>)

Original publisher: [Read original article](<http://androidessence.com/breaking-the-buzzwords-barrier-viewmodel/>)

Author: Adam McNeilly

Published: 2018-06-01T00:00:00Z

Content type: tutorial

Language: en

Sources: [Android Essence](<https://devfeed.tech/sources/android-essence.md>)

Topics: [mvc](<https://devfeed.tech/topics/mvc.md>), [Android](<https://devfeed.tech/topics/android.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [rotation](<https://devfeed.tech/tags/rotation.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

This tutorial explains the difference between the ViewModel concept in MVVM architecture and Android's lifecycle-conscious ViewModel class. It describes how Android Architecture Components retain ViewModel data across configuration changes such as rotation.

### Source excerpt

So far we've covered four big buzzwords used in our application: Model-View-ViewModel Room RxJava Repository Pattern Now, we should circle back to the beginning. Following our diagram outlined in the previous parts, the next component we can begin to work on is our AccountViewModel: Naturally, this may bring up some confusion. We already discussed ViewModels in part 1. Well, depending on context, we may not be referring to the same thing.

## Using Kotlin to Simplify Android Architecture Components

DevFeed: [Using Kotlin to Simplify Android Architecture Components](<https://devfeed.tech/articles/hacking-architecture-components-by-using-kotlin-27135.md>)

Original publisher: [Read original article](<https://antonioleiva.com/architecture-components-kotlin>)

Published: 2018-03-13T00:00:00Z

Content type: tutorial

Language: en

Sources: [Antonio Leiva](<https://devfeed.tech/sources/antonio-leiva.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Android](<https://devfeed.tech/topics/android.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [livedata](<https://devfeed.tech/tags/livedata.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

This tutorial introduces Android Architecture Components, focusing on ViewModel and LiveData, and shows how Kotlin can make their use simpler. It also discusses lifecycle handling, configuration changes, and testing.

### Source excerpt

Everything Android, Kotlin and other random topics

## Using Android Architecture Components with Firebase Realtime Database (Part 3)

DevFeed: [Using Android Architecture Components with Firebase Realtime Database (Part 3)](<https://devfeed.tech/articles/using-android-architecture-components-with-firebase-realtime-database-part-3-16248.md>)

Original publisher: [Read original article](<https://firebase.blog/posts/2017/12/using-android-architecture-components_22>)

Author: Doug Stevenson

Published: 2017-12-22T00:00:00Z

Content type: tutorial

Language: en

Sources: [Firebase Blog](<https://devfeed.tech/sources/firebase-blog.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Realtime Database](<https://devfeed.tech/topics/realtime-database.md>), [Firebase](<https://devfeed.tech/topics/firebase.md>), [Database](<https://devfeed.tech/topics/database.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-architecture](<https://devfeed.tech/tags/android-architecture.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [best-practices](<https://devfeed.tech/tags/best-practices.md>), [firebase](<https://devfeed.tech/tags/firebase.md>), [net-conf](<https://devfeed.tech/tags/net-conf.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [performance](<https://devfeed.tech/tags/performance.md>), [realtime-database](<https://devfeed.tech/tags/realtime-database.md>), [threading](<https://devfeed.tech/tags/threading.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

This tutorial explains how lifecycle-aware Android Architecture Components work with Firebase Realtime Database. It focuses on LiveData and ViewModel, threading for expensive data manipulation, and the performance cost of removing and re-adding database listeners during Activity configuration changes.

### Source excerpt

News, tutorials, and updates from the Firebase team.

## Using Android Architecture Components with Firebase Realtime Database (Part 2)

DevFeed: [Using Android Architecture Components with Firebase Realtime Database (Part 2)](<https://devfeed.tech/articles/using-android-architecture-components-with-firebase-realtime-database-part-2-16247.md>)

Original publisher: [Read original article](<https://firebase.blog/posts/2017/12/using-android-architecture-components_20>)

Author: Doug Stevenson

Published: 2017-12-20T00:00:00Z

Content type: tutorial

Language: en

Sources: [Firebase Blog](<https://devfeed.tech/sources/firebase-blog.md>)

Topics: [Realtime Database](<https://devfeed.tech/topics/realtime-database.md>), [Firebase](<https://devfeed.tech/topics/firebase.md>), [Android](<https://devfeed.tech/topics/android.md>), [Database](<https://devfeed.tech/topics/database.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-architecture](<https://devfeed.tech/tags/android-architecture.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [best-practices](<https://devfeed.tech/tags/best-practices.md>), [database](<https://devfeed.tech/tags/database.md>), [firebase](<https://devfeed.tech/tags/firebase.md>), [realtime](<https://devfeed.tech/tags/realtime.md>), [realtime-database](<https://devfeed.tech/tags/realtime-database.md>), [sdk](<https://devfeed.tech/tags/sdk.md>), [tutorials](<https://devfeed.tech/tags/tutorials.md>)

### AI overview

This tutorial shows how to use Android Architecture Components with Firebase Realtime Database to map database snapshots into application objects and keep database-specific logic out of an Activity. It uses transformations so UI-facing objects are ready for display and the app can later switch database implementations with fewer Activity changes.

### Source excerpt

News, tutorials, and updates from the Firebase team.

## Avoiding LiveData observer leaks in the Android Fragment lifecycle

DevFeed: [Avoiding LiveData observer leaks in the Android Fragment lifecycle](<https://devfeed.tech/articles/architecture-components-pitfalls-part-1-25878.md>)

Original publisher: [Read original article](<https://bladecoder.medium.com/architecture-components-pitfalls-part-1-9300dd969808?source=rss-54910f05af37------2>)

Author: Christophe Beyls

Published: 2017-10-24T19:31:14Z

Content type: tutorial

Language: en

Sources: [Stories by Christophe Beyls on Medium](<https://devfeed.tech/sources/stories-by-christophe-beyls-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [configuration](<https://devfeed.tech/topics/configuration.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [deprecated](<https://devfeed.tech/tags/deprecated.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [livedata](<https://devfeed.tech/tags/livedata.md>), [memory](<https://devfeed.tech/tags/memory.md>), [memory-leak](<https://devfeed.tech/tags/memory-leak.md>), [performance](<https://devfeed.tech/tags/performance.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

This article explains a pitfall when subscribing to LiveData from an Android Fragment. Detaching and re-attaching a Fragment can create a new observer while the previous observer remains active, causing duplicate execution, a memory leak, and a performance problem until the Fragment is destroyed.

### Source excerpt

LiveData and the Fragment lifecycle The new Android Architecure Components are soon to be announced as stable after a few months of public testing. A lot has already been written about the basics (starting with the very good documentation) so I won't cover them here. Instead I would like to focus on important pitfalls that are mostly undocumented and rarely discussed and may cause issues in your applications if you miss them. In this first article, I'll talk about our beloved Fragments. Edit (14 may 2018): Google has finally fixed the issue in support library 28.0.0 and AndroidX 1.0.0. See solution 4 below.Edit (13 march 2020): onActivityCreated() has been officially deprecated and onViewCreated() should be used instead. The code samples in this article have been updated accordingly. The Architecture Components provide default ViewModelProvider implementations for activities and fragments. They allow you to store LiveData instances inside a ViewModel to be reused across configuration changes. The usage with activities is quite straightforward because the activity lifecyle maps well to the Lifecycle interface of the Architecture Components, but the fragment lifecycle is more complex and may cause subtle side effects if you're not being careful. The Fragment lifecycle (simplified version) Fragments can be detached and re-attached. When they are detached, their view hierarchy is destroyed and they become invisible and inactive, but their instance is not destroyed. When they are later re-attached, a new view hierarchy is created and onCreateView() and onViewCreated() are called again. For this reason, the usually recommended place to initialize Loaders and other asynchronous loading operations that will eventually interact with the view hierarchy is in onViewCreated(). We can assume this is also the best place to initialize LiveData instances by subscribing a new Observer. Most of the official Architecture Components samples also do it there. You would expect typical co

## Doppl Updates - Kevin Galligan

DevFeed: [Doppl Updates - Kevin Galligan](<https://devfeed.tech/articles/doppl-updates-kevin-galligan-38191.md>)

Original publisher: [Read original article](<https://touchlab.co/doppl-updates>)

Published: 2017-10-20T15:31:18Z

Content type: release

Language: en

Sources: [Touchlab | Enterprise Mobile Innovation & Development](<https://devfeed.tech/sources/touchlab-enterprise-mobile-innovation-development.md>)

Topics: [iOS](<https://devfeed.tech/topics/ios.md>), [RxJava](<https://devfeed.tech/topics/rxjava.md>), [reactive](<https://devfeed.tech/topics/reactive.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [Xcode](<https://devfeed.tech/topics/xcode.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-architecture](<https://devfeed.tech/tags/android-architecture.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [build-system](<https://devfeed.tech/tags/build-system.md>), [built-by-touchlab](<https://devfeed.tech/tags/built-by-touchlab.md>), [code-sharing](<https://devfeed.tech/tags/code-sharing.md>), [droidcon](<https://devfeed.tech/tags/droidcon.md>), [framework](<https://devfeed.tech/tags/framework.md>), [ios](<https://devfeed.tech/tags/ios.md>), [press](<https://devfeed.tech/tags/press.md>), [reactive](<https://devfeed.tech/tags/reactive.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>), [swift](<https://devfeed.tech/tags/swift.md>), [updates](<https://devfeed.tech/tags/updates.md>), [xcode](<https://devfeed.tech/tags/xcode.md>)

### AI overview

Doppl updates include approval of the Droidcon 2017 app on Apple, an iOS project using a reactive architecture with RxJava 2 and Android Architecture components, and updates to those components. The article also describes a simplified Xcode build system and planned documentation assistance from Mark Murphy.

### Source excerpt

We've been super busy updating lots of stuff after Droidcon, and since nothing is ever really "done" I wanted to share a few big things...

## Getting Started With Room Persistence Library

DevFeed: [Getting Started With Room Persistence Library](<https://devfeed.tech/articles/getting-started-with-room-persistence-library-22809.md>)

Original publisher: [Read original article](<http://androidessence.com/getting-started-with-room-persistence-library/>)

Author: Adam McNeilly

Published: 2017-06-10T00:00:00Z

Content type: tutorial

Language: en

Sources: [Android Essence](<https://devfeed.tech/sources/android-essence.md>)

Topics: [Library](<https://devfeed.tech/topics/library.md>), [Persistence](<https://devfeed.tech/topics/persistence.md>), [Database](<https://devfeed.tech/topics/database.md>), [SQLite](<https://devfeed.tech/topics/sqlite.md>), [Development](<https://devfeed.tech/topics/development.md>), [To-Do](<https://devfeed.tech/topics/todo.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-architecture](<https://devfeed.tech/tags/android-architecture.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [architecture-components](<https://devfeed.tech/tags/architecture-components.md>), [code](<https://devfeed.tech/tags/code.md>), [component](<https://devfeed.tech/tags/component.md>), [database](<https://devfeed.tech/tags/database.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [google](<https://devfeed.tech/tags/google.md>), [interface](<https://devfeed.tech/tags/interface.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [library](<https://devfeed.tech/tags/library.md>), [list](<https://devfeed.tech/tags/list.md>), [migrations](<https://devfeed.tech/tags/migrations.md>), [persistence](<https://devfeed.tech/tags/persistence.md>), [published](<https://devfeed.tech/tags/published.md>), [room](<https://devfeed.tech/tags/room.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>), [sqlite](<https://devfeed.tech/tags/sqlite.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

### AI overview

This tutorial introduces Android's Room Persistence Library, an abstraction layer over SQLite, and demonstrates building a todo list with Room and RxJava. It covers project setup, entities, DAOs, CRUD methods, RxJava integration, and the AppDatabase class.

### Source excerpt

This year at Google I/O, the Android team announced Android Architecture Components a combination of new, helpful libraries for Android development. One that particularly interested me was the Room Persistence Library, which is an abstraction layer of SQLite designed to make database access and creation a lot easier. Right off the bat it reminded me of Realm, which I learned about at Droidcon NYC and really admired, so I decided to dive in and build a todo list using Room & RxJava.