The best reports on Google I / O 2017: Architecture and more

    Hello! My name is Mikhail Barannikov, I am an Android developer in e-Legion. He recently returned from Google I / O and decided to share his impressions and links to interesting presentations. In total, the conference had 14 parallel tracks, which means a huge number of reports. This article is useful for those who plan to watch video reports of reports on Android development, but do not know where to start.



    Program


    Each Google I / O member immediately selects the events they want to attend. They are divided into several types:

    • Reports - learn about what's new, how to use it.
    • Sandbox demo - demos of Daydream and Tango.
    • Office hours - the ability to ask speakers questions to solve their pressing problems.
    • App review - consult on the topic of your application (how to develop, how to develop, where to grow).
    • Codelabs - try everything presented in the case.

    The reports are divided into several topics: Android, Firebase, cloud technology, in-app advertising, Google Play, assistant, design, mobile web, machine learning & AI and others. It’s easy to select reports by categories: are you developing mobile web applications or are you interested in things like Flutter and React Native - go to the mobile web if you are interested in artificial intelligence and machine learning - for events related to them.

    I set the filter on Android in the Google I / O application and selected the reports of interest to me from the list presented, adding them to “My I / O”.

    Most of all I was interested in reports about architecture and application optimization. There is no ideal architecture, so I wanted to see what the guys from Google would offer. And they suggested: they tried to solve the problems that everyone was tired of for a long time. Namely: binding to the life cycle, saving queries / data during turns, pleasant work with the database. They also told how to reduce apk size and speed up gradle build. Unfortunately, even being present at I / O, one cannot see live all the interesting reports, because some go in parallel.

    Below I will tell you more about some interesting reports.

    Life Cycle and Turns


    Lifecycle, LifecycleActivity, LifecycleFragment, LifecycleOwner, LifecycleObservable, LiveData have been added.

    Using the above, the developer will be able to become attached in the life cycle of activity, fragment or the entire application. To do this, you need to implement the LifecycleObservable interface. Without going into too much detail: with a Lifecycle object, you can check the current state of the life cycle, or subscribe to specific life cycle events using annotations. This will allow you to write components that work in accordance with the life cycle, and get rid of a bunch of code in onResume / onPause.

    LiveData is an Observable that knows and works according to the life cycle. This is very useful if you want to start downloading data when subscribers appear or stop downloading if there are no subscribers. After the download is complete, we call setValue (), and all subscribers receive this data.

    But we also want to save queries and data when cornering. To do this, we are offered to use ViewModel. In it we can store our LiveData. ViewModel is not destroyed when the screen is rotated. We can get ViewModel using ViewModelProviders.of (FragmentActivity) .get (MyViewModel.class). If the ViewModel is not created, then a new one is created, if it is already created, the old one will be returned to us. Since the ViewModel is LiveData, the rest of the code remains the same. We get LiveData and subscribe to them. It is important to note that when subscribing to LiveData, if there is already data there, they will be returned to us immediately. In fact, it works like the well-known BehaviorSubject from RxJava, but at the same time as part of the life cycle.
    Watch from 1:00. This video describes Lifecycle, LiveData, and ViewModel in more detail.



    Database


    Room was introduced. It should save us from boilerplate code, work with SQLite and provide compile-time verification. Room using annotations allows you to work with the database. Unfortunately, you have to write SQLite queries by hand. But then all the power of SQLite is at our service. When working with Room, you will need to create Entity data classes, a Dao interface, and a Database class. Some shortcut annotations are also available to us, so as not to write very simple SQL queries: Insert, Delete, Update. Room can return LiveData, which gives us the opportunity to subscribe to database updates without loaders. How long have we been waiting for this. Well, the final touch - Room supports not only LiveData, but also RxJava 2 Flowable.

    Watch from the second minute. Here is more about the new approach when working with databases. Additionally talked about migration.



    If you have very little time, but I want to see about architecture, then you can use the video on YouTube, start watching from 6:30. The architecture itself is explained starting at 28:20. This video provides a brief overview of architectural components.



    It's nice that they hear us and offer tools for solving problems. Now there are many test projects using this architecture. The tools presented are encouraging. Will they be able to solve the tasks and existing problems - time will tell. It is also worth noting that this is not an ideal architecture and everyone should use only it. It was said that if you have your architecture and it works well, then you can safely leave it. If you are starting a new project, you can try this approach.

    My personal TOP reports besides architecture


    Best Practices to Slim Down Your App Size
    How to reduce the apk file size, which leads to fewer cancellations of downloads. How to reduce the amount of space occupied by resources and classes. Useful in product development.

    Speeding Up Your Android Gradle Builds
    How to speed up your build in 10 steps. Watch is the first half to the 22nd minute. Or watch immediately 22 minutes, where there is a list of all optimizations. One of the optimizations is the use of Instant Run. The last time I tried to use it a year ago, and then turned it off forever. The video says that they fixed many bugs related to the work of Instant Run. Well, maybe you should give him a second chance.

    Fragment tricks
    A bit of work with fragments. In general, nothing new was said. It just shows how to work with fragments, and talks about setReorderingAllowed (). Watch from the 7th minute.

    Best Practices to Improve Sign-In, Payments, and Forms in Your Apps
    Auto-complete forms in Android O and transfer application data between phones using the Account Transafer API. If the second is useful, the first is still relevant only for Android O (we are waiting for it to appear in the support library). The explanation of the system is from 4:45, an example of use is from 7:50. Data transfer starts from the 13th minute.

    Android Performance: An Overview
    A detailed story about Systrace and its use. Useful for developers who want to make the application as fast as possible. With Systrace, you can find bottlenecks in the application for optimization, but it will take quite a lot of time.

    Total


    General impressions of the conference are positive. I was pleased with the organization, the speeches themselves and the opportunity to chat, ask questions and get answers to them. It was a little disappointing that there is no huge innovation in Android O. At the moment, these are small changes aimed at more convenient work for both the user and the developer.

    The plans are to revise again the video from the conference. Interesting in my opinion reports can be found here .

    Also popular now: