Duration 34:07
16+
Play
Video

Android Jetpack: what's new in Architecture Components

Lukas Bergstrom
Product Manager at Google
+ 1 speaker
  • Video
  • Table of contents
  • Video
2018 Google I/O
May 8, 2018, Mountain View, USA
2018 Google I/O
Video
Android Jetpack: what's new in Architecture Components
Available
In cart
Free
Free
Free
Free
Free
Free
Add to favorites
63.51 K
I like 0
I dislike 0
Available
In cart
Free
Free
Free
Free
Free
Free
  • Description
  • Transcript
  • Discussion

About speakers

Lukas Bergstrom
Product Manager at Google
Yigit Boyar
Software Engineer at Google

Lukas is a product manager for Android developer frameworks and tools. He was previously product manager for Google Tag Manager. He has held roles as a software engineer, management consultant and program manager for an agricultural development non-profit.

View the profile

Yigit leads the Architecture Components for Android, focusing on the developer experience and dreams of making app development easy. Previously, he was working on Data Binding and RecyclerView in the Android Toolkit Team. Prior to Google, he was the Android engineering manager at Path.com. He received his B.S. in Computer Engineering from Middle East Technical University / Turkey.

View the profile

About the talk

This session will cover the state of the art in Android app architecture: all the new features and updates that have been added to Android Architecture Components since I/O'17, including the new Navigation and WorkManager components.

Share

Good morning. Prince everybody here Hi, I'm Lucas Bergstrom product manager for Android architecture components. And before I get started, I'm curious how many of you were here last year when we announced architecture components for the first time. Awesome. Okay. This is a much bigger venue. So that's actually a decent percentage when we did a launch architecture components last year. We were doing something sort of different for us for the first time. We were offering explicit guidance and

how to architecture app and giving you components letting you do that. And frankly for us. It was a little bit of a journey into the unknown so 12 months and let's check in on how we're doing. So we should point six releases since May last year. So we've been constantly iterating and improving the course at architecture components. In the sign of any healthy open source project with a very active issue tracker and like to thank everybody that's taking time to file a feature request or even a bug and we've closed a lot of those. We wants to meet you to library

paging which is now stable and we'll talk a little bit more about today and I'm pleased to say that based on our survey data over half of you are using or planning to use architecture components and this survey was done only a few months after we went stable. So this date is pretty out of date by now, but I'm pretty proud of the fact only a few months after launching to stable over half of the Android developers. We talk to you were planning to use this stuff. But more importantly than any of this you told us that architecture components actually make it easier for you to build

robust apps that having a clear path on how to architect your app and components that help you realize that has actually made a difference in the real world and how you build your apps and we've heard that not just once but we've heard that over and over from a lot of developers would have taken time to speak to us. So Architecture components has grown and where they continue to invest here. This is foundational. We think for Android apps going forward. But not just are we investing in architecture components

but this year with jetpack. We're going to take that same approach that we took his architecture components a blank sheet of paper approach to how Android developer experience should be and you know how we can improve things for you and Jetpack is going to take that and apply that to the rest of the developer API service that we offer. So now I'm going to turn it over to eat to talk about what's new in architecture components. Thanks for kids. Thank you. So

we will talk about it's about to be a being doing in this last one year. We'll look at the existing Library spoke about the improvements and also look at the new shiny stuff paging navigation Android manager. Let's start with life cycle of life cycles in the Lost, Iowa, but you better understand why we have created these components. Let's go to two years before in 2016. We did a bunch of developer surveys and ask developers. What is the hardest part of Android development and by far in the list big surprise was life

cycle management. What can be hard about a phone rotating or user switching applications? This happens all the time on Android Android is built for this. But if you look at the problem indeed tell if you want to handle them properly in your application, you need to understand this tape crafts very well and Mandy store in to lead it becomes very confusing. So we have created life cycles confident to get rid of these problems and seems to be working because many developers Los testimonios where a group of problems just disappeared from their

applications when they started using these libraries. Another important change for life cycles was one year ago. We have introduced them as an option a library, but now they are fundamental part of Android development. You don't need to do any additional libraries to start using them now both appcompatactivity and the fragment class Implement lost Cyclone. They're out of the box. Another interesting thing that happened was the community adoption. So we ourselves create new API. But we do other people doing the same in their libraries and

this is so much easier because already appcompat has this dependency so you can easily depend on them in your library is one great example of this is also disposed library from Uber using rxjava, but do you want the automatic life cycle management? You can just add this out of this world's coming to your stream. Give it a life cycle and it will manage the subscription for you for free. Not working on these things. You are also discovered more problems. We have one of them is the Frank Mastery of life cycle

through silver fragments. Main Street at the store serving live data, I go through the regular creation we created before it goes to the resume State at this point. If your new world is in your life beta will start displaying them everything works fine. So you want to detach this fragment because they're going to another fragment. Are you going to stop that pregnant? But lots of fragment is stuff. We don't need to leave for you like to reclaim those resources. So we destroy the

real later on. If you go back to the previous fragment be reattached it now because we have destroyed the wheel. Create a new one then go ahead and do it. But it's a brand new view. It's goes through the regular creation cycle. And now we have about this mean we will never resume the state of my they talk because you're using the fragment lifecycle bulb serve it so we don't tell me the reason to read this page to say it's kind of too late because only create you. You're you I had the best steak.

No, this is left you with two options. You did or subscribing on cray. Use looks really clean one-time setup, but it will fail if you recreate the view. So you need to to manually update the real you subscribing or creative which handles immigration, but now you have double subscriptions that you need to remove you lose automatic lifecycle management. Use the fragments have not one but two life cycles and we have decided to embrace it and give it a fragment view is on my cycle. Sono starting his support libraries 28 or Android text fragments

1.0. You can specify the real life cycle of Zuri if it is about the real you used to be life cycle. Otherwise use a fragment lifecycle manager subscription for you for free. Okay, so when we stopped at the look at our offerings as part of Japan will decide to move data binding as part of architecture components is our solar system for boiler play through your eyes. So if you're in your application in your binding layoffs, you can reference the fee senior object

and we take care of updating the ui4u in Dayton 23.1 native support for live data. So if you have a vehicle to like this which has a light of a user and if you pass it as a parameter to your whining you can use that lie data is if it's a regular field in your binding expression Beethoven, you will understand that is liletta and generate the correct. This is not enough for me to observe it because they have a life cycle when you get your binding yourself. You just tell it to beach life cycle that reduce it will start observing the light that

I keep itself after that. You don't need to write any calls for this. Beautifully written parts of the data mining compilot to be a lot more incremental. So if you have a project with multiple modules screen to compile a lot faster, we're also working on making compilation even more incremental, but they're not finished yet. Dispute compiler also gave us the ability to support instant apps you can use data mining in the future modules of your instant apps. Ok, Google my favorite architecture components

and your job or Courtland Court one important change with it in room. One point one was the support for better multi-threading stata into database this trying to read data while the right is executing. Your ribs will be blocked and it can only exist after the right is complete. A room appointment with the right there logging they can run in parallel and another nice feature of this thing. You're right run a lot faster than before. Best photos to change you don't need to do anything to take advantage of this if the device is running a Jelly Bean on ear

and it's not a low memory device. We are going to enable right now for free. Okay, another important addition to Rome was the support for real. But to better understand why we need to throw. Let's talk about the Creator annotation. You can spit fire is still pretty in the sanitation. You can use the name find parameters. You can pass those parameters as regular function arguments until the room what the return the best part of the setup is that room is going to validate all of this at compile time. So if there's a mistake in your pretty if

your permit test doesn't measure what you try to return doesn't make sense, it's going to fail the compilation and let you know what is wrong. Now this is all cool, except what if you don't know the credit compile time, but if you're writing your real estate application that users can search the houses with the price. Maybe they want Christmas find number of bedrooms bathrooms, whether it has a yard if you needed to quit init method for each relation of this that will be impossible to maintain What you doing? This case is you crave to be in Korea Trump time

based on the options user provider and you prepare the arguments for that credit database and use the square method to get the results so far. So good the problem with this approach. Is that it? Puma future so you're trying to get the list of houses. So this looks like a failure of the library has decided to introduce stroke wedding invitation. It looks pretty except instead of Swiss find the Crittenden Edition. You pass it as a parameter to the function. I don't you tell us what you want us to return

it anymore. So it's kind of you promised us to send the right. And we'll take care of it. Once you have that if we go back to our previous example, we can get any source of our dog. We need to merge Amor para meters and the query in the simplest guys critical Ops which is best way to hold her and then you can pass it to the door and get the list of horses No More Tears, no more boilerplate called. Okay paging so baking is our solution for lazy loading in recycle area

to go to an example. So you have at least like this is very common. Every single application has this user can scroll but you know, it takes you to represent a much larger list tan with sunscreen and if you're an application like this is a very long list, so you probably cannot see to the memory is also very inefficient to love. So what you do is you would keep some of it in memory of the database and you also have your server confidence by you put the stator from Implement properly. That's why we

have created the paging library to make this coming Falls Way easy and efficient employment. Pidgin Bible comes with a business class which is an actual Java list implementation, but it works with the data source, every time you access the items in the page list. It pulls data from the data source Leslie. So if user Scrolls, you need more data it just brings in more data. Melissa gets home. You can get a nuisance of these classes. It's just super easy. If you're using room room or did not have to pay the data source is a great example of how these

architectural companies work very well together so I can just tell the Roomba to return your data source or a data source Factory in this case. I'm using a data source Factory because they tell me is it something that changes and each pizza sauce represents a snapshot. So we need the factory so that we can Kranium data sources mandator exchanges that you can use this life page builder cuz it's the pace ice and cold build on it. It's going to give you a live dates off age to stop users. This is almost the same thing as lie, they don't list of users. Knowing your

activity or fragments you would use this page to set up there which is a recycling mirror adapter that works with baseless. You will observe the live data every time you have a new page this give it to the adapter. I know you said you're adopting you can just call this gift. I can function to attend. The user object. Is this super simple culture? Right? Imma take care of all the hard work of page and get laid for you. Bollywood life showing all those examples with light attack patient suffers rxjava out of the box. So if you're using an external and you want an observable of

faces, you can just get to Fear Factory. Room generates. What is that user RX Pages Fielder to build your own server or Floral? The physics of persuasion from the databases. I have shown here, but social support spacing from the network or you can combine both database and the network for the best user experience for more about it. Please join man, Chris Craig tomorrow at 2:30 in the paging session. All right. I'm all about Foo. I think possibly some of the suspense about what food is is gone now, but yeah, when you think about

sort of core problems that almost every app has to deal with in-app navigation has to be close to the top of the list there right now. The framework doesn't really offer anything for you, too. Do anything for you use their other than start activity, which the various reasons is not the best option. So that means that for navigation. There are a bunch of things that you have to figure out on your own and that ranges from executing a fragment transaction without throwing an exception, hopefully Passing arguments from place to place possibly even with type safety if you can figure

that out. Passing the navigation is working and that the right things are happening when you navigate from place to place. That's making sure to be up and back buttons were correctly and take the user where they're supposed to go. Mapping deep links to destinations in Europe and having that work and by the time you've solved all these problems you typically gone one of two directions, you've either written 60% of a navigation framework just for your app or you've got a lot of error-prone boilerplate. So everywhere navigation needs to happen. You got a bunch of parallel lines of code that need

to be changed anytime the navigational structure the app changes and this is all pretty riddle and can end up being a headache and individually these problems are pretty tractable. But when you compose them into a real world example So say that I have an item screen in my app maybe a product screen and that screen is accessible via deeplink. but Actually, there are other pages that you know, if the user had navigated here by opening the app from the home screen, they would have come via the home screen the category

screen and I want the up button to take them through those screens rather than exiting the app, right? So that means that if someone deep links into the app, I need to synthesize you screens and add them to the back stack but only on a deep lake and talk to a third-party developer or he said, you know, it's when you're in the middle of writing code to do this, you know on any deep linking to my app and synthesize the back that correctly you start to feel like maybe this is a failure of the framework. And so that's why we're really happy to be launching navigation. And which is a

Buffet runtime components that performs navigation for you and a visual tool that works with XML to define the navigational structure of your app and then, you know allows you to navigate runtime with a single navigate call. The kinds of things that you're going to get for free right that you simply needed to find an XML and then the navigation framework will handle it run time for you or animation. Passing arguments in a type Safeway from place to place making sure that up and back were correctly. And mapping

deep links to various screens in your app. And last but not least no more fragment transactions ever. So I'll show you a couple demos of this inaction. The first one is just the kind of give you an idea of what this all is. So we're looking at a set of fragment Trent fragment destinations in my app and I'm adding a new one and now I'm creating an action and this action is the thing that I'm actually going to call it run time to go from place to place and you can see that they're a bunch of other options. It will get into more in the

navigation talk. But the one thing I do want to show you the more the tail right now is the example we went through before so this is a simplified version of that where there isn't a category screen. We just have the home screen and then the item screen. But I'm going to right now configure this to both have a deep link pointing at the item screen and make sure that if someone deep links into the app that they go to the home screen first when they hit upper back rather than just exiting the app right away. So first, I'm just going to configure a deep link on the screen

and it the curly brackets that I'm going to put around item id indicate that I want to extract a variable there and pass. It is an argument into the item screen. Okay, and now that's ready to go and if I compile run my app that'll just work and navigate to the right destination. Now it is set the home screen to the start destination. That means that it's the hierarchical parent of all the other screens in the graph. So when someone deep links into the item screen and then hits up there going to go directly to that home screen. So now I can now I've just solved in 30 seconds. What would have

been a really terrible and time-consuming task in Java or kotlin back of the old world? Sonoma pass it out to eat to talk about work manager. I mean using navigation that couple of weeks for Sunday Moses feels like magic. So I hope you'll like it is a pleasure is over solution for the firbolg on teeth execution what I mean by this your actions on Android that you really really want to do if user. Something first diffuser size to send the three you want

to send it now, but if there's no network connection you want to send it as soon as device is connected to the internet. There's things like uploading looks you may want to do if the device is charging or you may want to play or decreasing your data with your back. And now we know this is not a new problem on Android and we had some solutions for this we have into this job scheduler in lollipop. I'm here five minutes drop the sweatshirt that back porch this function of the in the devices which has Google Play services alarm manager for exact time. Each of these has different

behaviors and different apis becomes very hard to implement that sits on top of them. I'm toys are much cleaner API with new functionalities what major has two simple Concepts? You have the workers that execute these actions and you have the work request which triggered these workers. If you want to look at the sample worker, this is basically all you do you extend Implement Mount function and that's what happened as a result of that work and you turned yourself. There's no service has no internet no

bundles nothing like that. Once we have the workers, we need to create a work request. So you can use this one time work Builders or there's a probiotic version of this one. You can specify to work across but no you can also add constraints. You can tell it on the down the stairs network connection with the device is charging or you can subscribe back of could I or should we try its input parameters today's workers once you built at work request you can get any sense of work manager and

entry. Brooke major will take care of executing it. One of the important distinctive features of work manager is that it has input and output semantics so your workers can receive input but they can also put some data you can observe this data through work manager was actually really useful to change your workers. Prima Jr. Have an application while using peaks in English from their device that you want the song round some image processing on the picture. I don't want this don't you want to upload it to your server. These are two different units of like

you can process the image. Maybe you want to do it when the device vinyl or you can do it anytime but to upload it to server you need internet connection, but you don't want to wait the processing for the entire population because it doesn't need it. This is she. Easy to implement in your manager. So have two different workers. They have single functionality. One of them does image processing upload to server? Okay, te helper function that receives an image file increase the process image work request. So prepared just uses the same Builder to produce

the request. Are we get that? Nobody wanted our Network upload to wait for the internet connection? So we set the constraint we say okay, wait for internet connection before trying to run this work because Unencrypted upload image were using that constraint begin with the process in which work once you're done than Land of the Silver Birch and then you ain't you two are both of these is an Ultima Corporation to the work manager that your device can restart anything can happen in between

we will take care of running Bluetooth. You can also use this API excessively like you could run image processing in parallel the same way. So if user pick multiple photos you want to process all of them, but upload it to server while so you can easily do that with your furniture will just use the same function or crate Rivercrest for each of the images user picks betrayed the upload work in the same. Maybe that before all this tree work items then run to upload work and then

you ain't you that is an automobile Corporation. I need takes care of running. Another important feature of work manager is that it is not just a report for job scheduler or fibers job this picture. It's actually executed itself. So let's get wild purchase take a vacation is important to use the euro to the fibers job dispatcher eventually call you to executed back. The problem is that you don't know how long it will take her convictions. It may take a couple of minutes for job scheduler to call you back and you have no control over. It just

don't know and it results in the bed user experience to work around that. What do you usually do is you also have your lunch at 4 whenever user hits and you try to run the same thing there as well and you take care of the duplicating run the Red Menace by the job scheduler calls you back if you are using work manager, you don't need to think about it because when you send the request of the major, it puts it into his own database tells job schedule. Call Richard schedule. It says on the device. Okay, I need to be involved when these concerns I met but it also takes those concerns

itself. And if they start executing the job if job scheduler comes and asks is the executive manager knows whether it is or not and handle the repairs properly. For more about the major, please join us today at 5:30 in the work major session. Alright, what's next? Okay, so I think it's been a pretty great year in Android app development. Hopefully you agree. We launched the set of brand new key components last year and we kept working on those endearing on

those. We've launched three new major components work manager and navigation and paging since then. So does that mean we're done obviously not we have a lot more to do. And the first thing we want to do is we want to make architecture component to the default way that people build Android apps and that doesn't mean that it's going to be required but it does mean that we want to make sure that as many people as possible, you know get it architecture components regardless of how they get in into Android development. So that means that not only we can be building more

tools like a navigation editor into Android Studio that are sort of architecture components aware, but it will also be any more templates that include things like the models. So that you know people starting a new project have easy as possible kind of on-ramp into Android development. And in terms of libraries, you know, not only we're going to be building more architecture components. And not only are we going to be building in more of the kind of core architecture components goodness, like life cycle awareness into jetpack, but we want to look at other Google apis as

well and see you know, how we can make those sort of architecture components to wear so that for example, you're calling another Google API, that's a synchronous write it already has that built in so that you're kind of getting architecture components benefits whether you know, you're using it or not. And then finally we've heard from everybody that you want us to speak with a single voice. You want us to give clear and consistent guidance. So that means that in terms of education and that means not just documentation, but it also means sample Ops Code Labs that

all the stuff is going to be refactor. They're going to be built on top of architecture components so that whether you know start with the guide app architecture or you just download a You Know sample Media Player app and to start customizing it that you kind of champagne and Redevelopment is that we get you the best possible place. We know that we still have some areas left to address in the core and you can see some of those here. So this is just to say that we are definitely not going to stop investing in the in the original set of

architecture components. Anderson not just problem solving year but some exciting stuff that we can do around how can we make architecture components as idiomatic and fun to use as possible for people using kotlin? So there's a lot to be done still in sort of I think the core set of app architecture and lifecycle problem areas. So we'll keep working there. But beyond that I think you'll see something interesting about our trajectory if we look at all the components. We wants the date so last year kind of this set of architecture components was you know, these are

relatively small pieces relatively small apis that are designed to be used in a lot of different places in your app. And then if you look at room navigation work manager, these are much larger and richer apis, but they're still relatively sort of self-contained right? They saw the single problem. They do it really well. Heejung also solves a single problem and solves it well, but in this case, we took a very specific use case, right so lazy loading for recyclerview, and we're actually in this case orchestrating multiple architecture components in pieces of Jetpack to

solve that problem. So paging is a little bit higher level. It's not just sort of here's your, you know object mapping layer, right? It actually takes a very specific. I know I have recyclerview with more data that I can fit in memory and uses multiple pieces of architecture components to make that is easy as possible and we want to continue to Inna build more stuff like that. So not Justa, we're not just going to keep investing in the core areas of architecture and life cycle, but we want to start solving higher-level problems and you'll make more and more as easy as possible.

But I can't leave today without thanking everybody that helped us get here. The reason that we were able to have a really high quality bar for architecture components was because a lot of people many of whom are here today. We're really generous with their time and that includes not just filing issues on the issue tracker, but also, you know, testing pre-release components having one-on-one conversations with us to tell you tell us what your biggest problem areas of Android app development were This has been critical to us and making sure that we're going to focus on the right

problems and delivering solutions that are going to work for you. So I really have to thank everybody in the community that's been so helpful.

Cackle comments for the website

Buy this talk

Access to the talk “Android Jetpack: what's new in Architecture Components”
Available
In cart
Free
Free
Free
Free
Free
Free

Access to all the recordings of the event

Get access to all videos “2018 Google I/O”
Available
In cart
Free
Free
Free
Free
Free
Free
Ticket

Interested in topic “Software development”?

You might be interested in videos from this event

September 28, 2018
Moscow
16
159
app store, apps, development, google play, mobile, soft

Similar talks

Yigit Boyar
Software Engineer at Google
+ 1 speaker
Chris Craik
Software Engineer at Google
+ 1 speaker
Available
In cart
Free
Free
Free
Free
Free
Free
Lukas Bergstrom
Product Manager at Google
+ 2 speakers
Ian Lake
Android Software Engineer at Google
+ 2 speakers
Sergey Vasilinets
Software Engineer at Google
+ 2 speakers
Available
In cart
Free
Free
Free
Free
Free
Free
Sumir Kataria
Software Engineer at Google
Available
In cart
Free
Free
Free
Free
Free
Free

Buy this video

Video

Access to the talk “Android Jetpack: what's new in Architecture Components”
Available
In cart
Free
Free
Free
Free
Free
Free

Conference Cast

With ConferenceCast.tv, you get access to our library of the world's best conference talks.

Conference Cast
558 conferences
22059 speakers
8245 hours of content