📜 ⬆️ ⬇️

Android Oreo: what can developers expect?

Is there something revolutionary new in Android Studio 3.0? What is the main disadvantage of Java 9 and what are the advantages of Kotlin? About this, as well as about profilers, compilers, IoT and much more - in our interview with Denis Neklyudov - the first developer from Russia who received the status of GDE.




Denis Neklyudov nekdenis is the first Russian developer who received the status of Google Developer Developer. He has a wealth of experience in developing applications for social networks, financial organizations, transport companies and advertising networks and agencies. Took part in a large number of projects, working on architecture, UI and UX. He speaks at various conferences, leads courses and blogs, including on Habré.
We asked him about the various features of the development for Android Oreo.
')
- In general, it is no secret that the recent release of Android Studio 3.0 is a kind of mini-revolution in the world of Android developers. For many, it means support for a subset of Java 8 functions (albeit not completely, but this is promised to be fixed in future releases). What Java 8 subset is now available out of the box and are there dependencies on the API level? What is the reason? At a minimum, the documentation states that Streaming or functional interfaces are available on Android with API level 24 and higher, and we are interested in the opinion of experienced developers on this issue.

Denis Neklyudov: Indeed, it is not by chance that the version was raised to the third. A major studio release is an excellent opportunity to try something new. I am a zealous supporter of the transition of Android development to Kotlin, so first of all I recommend paying attention to the improved support of the language from JetBrains in the new Android Studio. But I did not try the “desaharoz” of lambda, method referencing of default methods and other Java 8 buns. A detailed list of features is presented on the site . But, really, streams are not available. Why they did not port them is a good question. However, it is already possible at your own risk to use third-party ports, for example, this or that .

- Did the official Google support for the Kotlin language give any results in general? What has changed, in your opinion?

Denis Neklyudov: Google’s interaction with JetBrains has changed, which allows them to work more closely on Kotlin support. In particular, work began on the formation of the Kotlin Foundation, within the framework of which the issues of the future language and its support will be addressed. For those who lived with the plugin in IDEA or AS, in terms of new features, little has changed. But for those developers who were afraid to switch to Kotlin or try it, official support became a symbol of the fact that this is not just some experiment and a lot of geeks, but an officially supported language. And yes, now we need to remember Yoda Notation (smiles sadly).

- Kotlin is a new language and a new technology. One of the most frequent questions from a business is what to do if problems are discovered? How free are developers to accepting pull requests from other organizations? Do not have to wait ten years until your commit at all take a look? As far as possible, in the sense of the overall quality of libraries, the compiler, and so on — in a word, the entry threshold for a new developer?

Denis Neklyudov: Kotlin is relative to Java and especially C ++ is a young lad, but he is already seven years old and has been in the release for almost two years. So he is quite stable for serious implementation in production. Language support is so good that you do not need to do PR - just start an issue in the bugtracker, and the guys from JetBrains will fix the reasoned bug in the next build.

For developers unfamiliar with the language, the entry threshold is very low. The language is similar to both Java and many modern languages, including Swift. For the first acquaintance, we always recommend official training materials - they will quickly and clearly bring you up to date.

- Recently Java 9 came out. What do you think, how exactly will this affect Android development and will it affect you at all? It may be that the libraries are updated to nine, and we lose the ability to use them again?

Denis Neklyudov: I think that switching to Kotlin is one of the solutions to the lagging problem (in terms of development) of Android from Java. A large percentage of devices where we can not execute even Java 8 code. And thanks to Kotlin, developers can use many modern language gadgets, compiling them into Java 7 bytecode. The world of Android libraries has always lived on Java 7, and no one is porting them to Java 8. A great example of this is the super-popular Android RxJava 2 and its Java 8 alternative to Project Reactor, which no one on Android uses, including, therefore, now both projects (Kotlin and RxJava2) are actively supported and developed.

- What do you think about the fragmentation of the platform, given the increased number of languages ​​and their versions. What is the most reasonable strategy for supporting older versions and segmenting by generation of devices?

Denis Neklyudov: For me, little has changed over the years. Many new features of the SDK, fortunately, are back-billed to the Support Library, and the rest can be supported by checking the version of Android on which the application is currently running. At the moment, it is important to maintain the minimum version of Android 4.1. And focusing on the platform features - starting with Android 5. Although if I had a lot of money, I would, like Facebook, have two versions of the application - powerful with all the features, for new platforms, and a simple, low-consumption traffic and battery, with a minimum set features, but working on a Chinese plastic rattle for one and a half thousand rubles.

- Android Profiler - what do you especially like about it and what advantages can be noted?

Denis Neklyudov: I really like to watch the network activity of the application in it, I forgot about Stetho . It is also a great tool to look at memory allocations: who and how much they carry out. There is nothing better than systrace for analyzing CPU work, but you can quickly see it without leaving Studio, using a profiler.

- What is the Android Profiler from the inside? Is this a thing tied to Android Studio, or is the studio just calling the API of a particular subsystem? If there is some kind of backend there, it could be used for automatic testing or something like that. Now there is a very big problem in building devops-tulcheynov for mobile platforms, but few people understand how to do it correctly.

Denis Neklyudov: Profiler is part of Android Studio and does not have a headless API to use it without UI. Yes, and hardly need it. It is designed to search for memory leaks, analyze CPU usage and view network activity by humans. I do not think that this is the part of the process that needs to be automated at CI. If you dream, it would be great to receive reports on leakage and non-optimal algorithms from the build server, but now this is a utopia from the distant future.

- Java desktop developers have a special discipline - writing and debugging profilers. Should we also have ten different profilers for Android? In what situations should use Android Profiler, and where better to abstain? Should he always believe?

Denis Neklyudov: To be honest: the mobile world is changing so quickly that not every business can afford engineers who will be engaged in the meticulous profiling of an application. If the profiler power is not enough to study the traces, then the systrace power certainly should be enough. There is an excellent report on this, or rather two .

- Support Instant Apps - what is the main advantage of this technology? What is the use of developers and end users? Are there any restrictions on functionality when using this technology?

Denis Neklyudov: As soon as Instant Apps become stable, working everywhere and with bezazhzhnoy support from the development tools and build system, then a new era will come - applications without installation. Just imagine that you, like web pages, load the application screen by screen, just what you need.

Of course, standalone applications won't go anywhere. No one will open page-by-page, instant messengers, social networks, financial apps and games, but for example, opening a part of Uber from cards, paying for tickets from Posters, a shopping center card or an amusement park via QR or a link is much more convenient than installing application for one day, and even downloading the entire distribution of 4G.

For the developer, Instant Apps is a reason to clean up the architecture and structure of the application. Break it into independent or loosely coupled modules. But now a lot is not supported by the tools. For example, you cannot have a databinding layout not in the root module. And you need to keep track of the size of the Instant App, apk should not exceed 4 MB.

Restrictions in terms of functionality are also present, Instant Apps do not require installation, so they have less access to the system, its state and user data. But all the limitations are quite logical.

- Android Things - is there any difference from the "normal" Android? What goals does Google ultimately pursue by providing this system to consumers? What does this product mean to you? What are its functional differences from Linux for the same Raspberry Pi?

Denis Neklyudov: Android Things differs from the mobile version of Android by the absence of elements needed only by mobile devices, for example, Content Provider and custom keyboards. Instead, there are added API for working with I / O devices.

Of course, AT was created specifically for Internet of Things, and not just microcontrollers with some kind of program. Power devices and a wide range of ready-made tools allows you to fully utilize the potential of the device connected to the network. A striking example is the use of AT-devices as a central hub for sensors and controllers, and their power allows, without waiting for a response from the network, to make decisions on their own, because on AT you can even use TensorFlow.

When using Raspbian, for example, on Raspberry Pi 3, you will not be able to use a wide range of Google services, such as Firebase Cloud Messages, Firestore, Fuse Location Provider and many others. In addition, the Raspberry Pi is a device for the home hobby, not for industrial use. Android Things, in turn, works on commercially ready-to-use SoMs, such as NXP pico i.mx7d.

About Android Things in my podcast there is a whole issue-interview with Dave Smith, a team representative on Google . And for me personally, the opportunity to combine hobbies with my favorite libraries, familiar language and the SDK is a great pleasure that I get in the evenings by automating my home tasks. So, for example, in Poland on Google Developer Days I exhibited my control of air conditioners , where the central unit worked on AT.

And about how to make your smart device, I will tell the day before Mobius ...

- There is a question about compilers. Obviously, Jack toolchain finally goes into oblivion, and in its place comes the new Dex compiler (in Android Studio 3.0, it is still a preview, and since 3.1 it is already used by default). How is he better than Jack and how does this ultimately affect development? What optimizations are used?

Denis Neklyudov: A new Dex compiler called D8, which reduces the size of the application a bit at the expense of more compact Dex files, and Jack is not exactly connected. But Google abandoned its incomplete compiler, that's a fact. The development of the new Dex practically does not affect, except that you can otgresti bugs in unexpected places, as it is not debugged to the end.

- How do you think the guys from Google have achieved native support for features from Java 8? What changes has the Android runtime undergone?

Denis Neklyudov: Well, this is not native support, but the conversion of language “sugar” into baytkod. They produce desaccharosis and form a baytkod, imitating what is being created in Java 8. But, of course, it’s impossible to back-up, but this is an excellent reason to abandon retrolambda.

- Taking into account support of features from Java 8, does this provide an opportunity to use Scala> = 2.12 for development? In general, the logic is as follows: the new toolchain uses javac -> desugar -> dx. Java is a language officially supported by the developer. However, it should be borne in mind that desugar & dx rely on jvm byte code, so it should be possible to connect other languages ​​that generate it. In theory, there may be problems converting from jvm-bytecode to dalvik byte code, since Scala generates code differently than javac. For example, there may be a problem with the byte-code instruction invokedynamic. So will desugar support all valid Java bytecodes in the future?

Denis Neklyudov: Invokedynamic is not in the old SDKs, so it was impossible, among other things, to make the port of all Java 8 chips. Hardly anything else would be added to desugar. Scala and Android very rarely overlap, and, given the support of Kotlin, I personally don’t know why to spend an already short life on pulling at the ears of someone else’s language, which is good in its segment, but not in the world of mobile development.

- Among the nice innovations in Android 8 can be noted the addition of java.nio.file and java.lang.invoke. What are the benefits of these new APIs and in which scenarios is it better to use them?

Denis Neklyudov: Do not forget that a couple of years must pass in order for developers to put minsdk 26 in their applications in order to rely on these APIs. But in general, they are useful to those who write specific libraries.



If mobile development is your main reason, and you like to savor the details, you will surely like these reports at our November conference Mobius 2017 Moscow :

Source: https://habr.com/ru/post/341896/


All Articles