What's New in Android Studio (Android Dev Summit '19)

[Music] welcome to our session on what's new and Android studio my name is Jamal and asked with me tour today today we're going to talk about all the latest new features inside of Android studio plus take a deep dive when some things are heard about during the Android developer summit keynote as a frame it for a session today we'll talk about features that are available in stable today all the way to the bleeding edge features should find in the canary channel alright to get us up to speed let's take a quick step back at Google i/o we launched Android studio 3.

5 into beta debri focused on system health feature polish and our bug bug backlog just this past month we launched Android studio 3.

6 into the beta channel that had things like few bunny support emulator with integrated Google Maps designed tools improvements and Kotlin and J&I support and today we're excited to talk about a little bit more about Android studio 4.

0 okay with this context let's talk about what's inside of our stable Channel today to recap Android studio 3.

5 focus on three main pillars system health feature polish and our bug backlog now that all culminated in something we called Project marble now specifically project marble included a number of smaller projects that our team worked on across the board things like crashes improvements to apply changes hangs CPA usage for the emulator our eight improvements in our bug backlog now I want to talk about some of the improvements but also the successes of project marble so you for your awareness okay one of the first issues we talked about and worked on it was around hangs and latency for this specific example on the screen we looked at XML typing and data binding what we found is some there's some critical bottlenecks we had in typing so we analyze and improve those things we did that not only for XML we do that for Java and the Kotlin programming languages as well another pain point we heard from you it's about memory and the symptom of this is that hey the idea is slow and not responsive and the root cause of that is actually the memory issues itself so the first thing we did is actually created a new set of infrastructure and dashboards to catch these issues as we checked in code into Android studio and of course we can't catch everything so then we added a new set of client-side analysis for you so if you notice if an der city is slower and sluggish you can now create your own heaped up and have a sanitized version up heaped up you can share with us so we can understand what's going out your machine and how to best solve those problems then lastly we heard a lot of people complain about sort of the overall speed of Android studio and we found from the optin data is that a lot of people are using the default settings of an der city well this is fine for intra projects and beginning projects but as your project expands you add more functionality you can actually increase your heap size for a better performance so if you ever see this pop up menu come up in the in the bottom right hand corner of Android studio please look at that and accept those settings we've actually applied some analysis and some some models to understand how the best configure at your address video and your Gradle plugin to have better performance so speaking of the build speeds so you spent a lot of time during a project model to look at how to improve build speeds so before project marble we had about a 12 point 5 second average build speed and we drove that down to about nine point five seconds post Android city post some project marble digging a little bit into data you saw this morning specifically we're actually working on build speeds along the way from thread o all the way to three point three but what's happening we noticed is that products are just becoming more complex either if he added an efficient processors are more features to your build speeds it's just slowing down a weren't able to keep up so in the 3.

33 got for time frame we now were able to stabilize that and what we're excited about is with Android studio Gradle plug-in three point five we actually have seen a decrease in build speeds so if you haven't moved to Android studio Gradle plug-in three point five I highly encourage it to take advantage of all the major improvements for a build speed and last we looked at for us is on deployment speed so deployment speed is the time it takes for you make a change on Andrew studio and sit on a running device or emulator so the medium before that before partner marble is about seven point nine seconds and we draw that down to about three point six seconds and that was all around the feature called apply changes and apply changes if you don't know is there placement to instant and apply changes is a fast in turf way to make changes to your application so we haven't been using apply changes I highly encourage us uses that as well because hello dramatically and crew improve your incremental change in workflow in developing with your app and Android studio all right so recap we've done a number of improvements for project Marple and are really excited about those things and thank you to all of you who fought bugs and share with us opt-in data without that information you wouldn't know what to prioritize to make things better for your development the quality is definitely not done but we set a new quality bar for our cells they want to maintain going forward so with this quality bar set for it for ourselves we would have continued working on new features for Android studio so today we're give you a preview of a lot of new things we're working on inside of Android studio but before we migrate those features from canary to staple we're gonna prioritize and assess those features and match them to the quality bar that we set during project marble so instead of talking about all those cool features we added to Android studio I'm gonna have tor walk us through some of the cool things we have inside of Android studio all right Thank You Jamal so one thing we hear over and over again is that you want your builds to run faster and as you just saw we've been making some good progress but as you'll see shortly just speeding up the android plug-in is only part of the puzzle so when you want to write your apps and make them faster you run a profiler right well what we've been working on is a profiler for your builds so I'm gonna show you what that looks like so this is the Santa tracker Santa tracker project with some deliberate build mistakes I've added in and after you've built now you get this new build speed task one for each build that you've run and this gives me a breakdown into what happened during the build so for example here I have a breakdown of all the tasks that determine the build duration right so this is showing me the tasks are on the critical path there's no point in trying to optimize a task that is not on the critical path you make it faster you're still waiting for a longer task right we also give you a breakdown of the build time for each plug-in so you can see here I have a plug-in that's taken up for percent of this build this happens to be a third party licensed plug-in so what is doing is very valuable it's fetching license files over the network and inserting it into the help menu but maybe I don't need to do that on every single fold debug build right so I can may be investing it you're getting release builds so this gives me an insight that I can then go and do something about we also try to surface a bunch of problems in the build so for example always run tasks tasks should only run when their inputs have changed but as you can see these tasks are not actually declaring their inputs and that means they're gonna have to run every single time so if this is your task then you know you should fix it otherwise you should contact the author and ask them to fix it another problem that we pinpoint for you here is task setup issues so if you configure multiple tasks to share the same output directory then they can't run incrementally so if you do that you're breaking incremental compilation and again we're surfacing that to you right here listing the tasks that are conflicting non cashable tasks this is pretty important if you want to use the distributed cache these are not going to work and then of course non-incremental annotation processors so if you use an annotation processor that's not incremental aware it'll force a full rebuild and they all have to be incremental aware now we've been working on a lot of them and working with you know annotation processor authors to actually update to Gradle support for increment incremental api's and so in some cases it's as easy for you as updating to the latest version so when we know for example here we're telling you Auto value switch to version 164 and your build rule on faster and then there's configuration time so configuration is where tasks are created whether or not they're going to run this is supposed to be a very fast operation but some plugins will actually do a lot of computation during configuration I've actually created a slow one here that waits for two seconds and that's you know it's simulating doing lots of computation that you shouldn't but this gives you a chance to sort of dig in and see exactly what's going wrong so as I mentioned you get one build speed tab each time you invoke the build so I did a full build here for about three minutes to three minutes I then did an incremental bit so now I can see the breakdown of what happens in micro mental build you can see the licensing is no longer the issue here and so by breaking this up for each build you can decide whether you want to optimize for CI the full build scenario or if you want to optimize for your incremental build in the IDE or preferably both but you're probably going to have more value out of the incremental builds as you do those over and over and over again so that's the new build attribution feature that we have in forw it's not actually in canary 1 but hopefully we will land it soon all right so while around the topic of Gradle we now support the cotman Gradle DSL so that means that you can write your build files in Kotlin and that's really good for the IDE because we can reason about Kotlin it statically typed so the editor support is better and so for example code completion now if you've ever wondered what you're allowed to configure inside default config well wonder no more you can see the exact list here similarly you know lint options if you want to know what you can invoke and what you can customize they're listed here and you can also pull up docs for the DSL which is pretty handy right from the IDE [Applause] we also run lint on your kts files and in 4.

0 the biggest amount of work for us was to implement the ability to read analyze and write this build files so the product structure dialog now also handles Kotlin dsl so i can go in here and i can accept these suggestions to update to the latest version of these libraries for example and then hit update and then it's gonna do it's gonna rewrite the build file and run another sync okay let's see let's go to number two so let's take a look at the compile options section you'll see this new flag here called core library to sugaring enabled so this is for a new feature in forw called library de sugaring and this lets you access api's that normally require higher api level on an older API level what we do is we rewrite those calls into a backboard library that we bundle with your app so let's take a look at what that looks like so here I'm using Java util stream and Lent tells me that this is going to crash prior to API level 24 right so you can't use it right well now if you turn on library your sugaring it's actually complaining in this module because this module this code isn't in the module right turn on library to sugaring but if I switch to the same code in my library distribute module you can see lint is happy because this is gonna work and let me show you the bytecode to see how this works so this is the same method I just showed you and if we look at the bytecode you can see that Java util stream has been replaced with this Jade dollar util stream that's basically the backboard library and it's good to be aware of this because you might see these package names in you know stack traces and debugger and so on and note that this is not limited to Java util stream you can use this for Java time you can use it for word job of that util that function Java util optional and we even rewrite references to concurrent hash map because it turns out that on some devices concurrent hash map has a really bad bug and so by using this feature we will just replace your concurred usages with the safe one and you won't be bit by that bug all right speaking of Dex of the eighth and r8 for Coach drinking we still use ProGuard files to drive the process and so in forw we've improved our support for ProGuard files we have better code completion we have goes to declarations and the most important part is that it is now find usages and you're factoring aware so if I for example rename this class that happened to be referenced from a ProGuard file and I apply that you're factoring you can see that the ProGuard file is also updated so no more you know stale Program Files after this all right so back to our Gradle file yet I've also turned on view binding so view binding is very much like a data binding but it is easier to use and it is it has a smaller impact on your build speed so once you turn this on it'll create a binding class for each one of your layouts so here's a class that first does things the classic way right so we have a set content view will be pass in a layout resource then we fish around in the view hierarchy with these five methods we apply a cast that'll hopefully work and then we take our chances accessing that object with you binding what we do instead is we access or inflate the layout with this generated binding class and now we get this binding instance which knows exactly which views are present in the layout so in this case textview is present in all versions of activity main so that means that we know it's non null Abul and it's safe to access I will have no null pointer exceptions with this one new binding knows that button is actually missing from one of the layouts so it's marked as nullable and if I haven't use the Elvis operator here cotton would refuse to compile so via binding is great for caching nullus it's and it's also pretty good performance all right so the binding makes it really easy to access and update your views but we're working on a brand new framework to make it even more powerful in DC and that's jetpack and post so this is hello world from compose so what we do here is we can take an existing composable or a widget and we can wrap it in our own function and customize it with some arguments and as soon as we put a composable annotation on it voila we've created our own widget and we can also mark it with this preview annotation and then it shows up in a preview pane inside the cotman file this is a bit like our sample data support in the old layout editor but now applied for a compose and so we've created our own widget called greeting here we can take that further and you know we can throw a for loop around it and other conditionals and we can wrap it inside another composable so you compose new widgets by adding composable so you know the name makes a lot of sense so we have the preview again and note that this preview is not limited to one so here I have a button widget that I've created it has two States on and off and notice how I can preview all the states including in dark mode as well which is pretty handy and here's an even more complex example from our newsreader app so this is a card we used to show available stories and here you can see we're also showing you for example what this looks like with a larger system font so the embedded preview is really great for tweaking your views as well as seeing what they'll look like across different dimensions like theme and font size and things like that but sometimes you really want to run the app to modify the behavior and so I'm very excited about this next feature if you watch the keynote you've already seen it but I'm still excited about it this is a feature I've wanted since before Studio 1.

0 but it was very technically challenging but the team is in the process of pulling it off and that is of course the ability to have the emulator embedded inside the IDE yeah I love this so yep so this is the real emulator right it's not just simulating the app in isolation I can install account I can launch intense and all that and what's nice about having it inside the IDE is that it participates in window management right so if I'm the source editor and I want to focus I press the key mining I'm in my editor and I can bring it back very easily so it's it's super convenient so this is my compose app running we can drill into it here and let's click on the bookmark icon and when I do that I'm launching an attempt and that's actually not what I want to do so I've introduced a bug in the app so let's just go and fix that so I'll jump to the related code this is a toggle bookmark code oh yeah I had it to do here and a stop marker – let's try apply changes and it's now reloaded the app and I can invoke the bookmark and it works so this combination is pretty productive right here running in the IDE one last thing I'll mention about our composer support is we were working pretty hard on making the editor experience better right so for code completion for example we are ranking composable to the top notice that we're also normally you'll have types on the right but we are removing types from the right so we have more space to show you all the parameters we're hiding defaults and we also have a special code completion insert handler so if I for example insert a row if I don't enter anything as a parameter and I hit enter we remove the parameter list and so on so we're trying to make this editor really smooth as you're working on compose okay we're also working on the classic view system so let me switch over to the layout editor it's the sunflower app so here's an XML file now you remember how in the compose file we included the preview right there in the source editor we've done the same thing for layout XML files we used to have a separate tool window and in the layout editor we had the sine of source tabs what we're doing now is instead we have these three buttons at the top this works in compose it works in the layout editor and you can use key bindings to quickly map between them so if I press ctrl shift left here I'm in pure source if I go to the middle one I can have them side by side and if I go all the way to the right I have the full layout editor and this also works for custom views so here I have an Android custom view and I now within the Java or Kotlin editor I could see my custom you when I'm tweaking the painting code it's right there and makes it a lot easier to work with right so let's look at the layout inspector so I'm gonna run this app and again open up the emulator alright so this is the layout inspector and actually that's not that still that's the app running this is the layout inspector and it's gonna attach to my running app so you know I okay it's already connecting so what it's doing now is it's gonna pull down the whole view hierarchy there it is let's give yourself some more space so the first thing I can do here is I can click on various views and I can see their values we had that in the old layout inspector but what's new is this declared attributes section so here you can see resources that are coming from binary resources or XML resources so let's take a look at the label ad plant where's that coming from well I can expand that and I can see that was actually specified right there in the layout file and I can continue with the whole resolution stack and see the exact line and language that it came from and normally it's not difficult to find where string came from you can search for it but what about colors so you can see that this bucket has a green color where's that coming from and again I can expand and you can see we have multiple alternatives here and it's probably too small for you to see I mean I can barely see it from here but there's strikethrough on all the theme references for material where this normal this color would normally be specified as grey instead we have some other attributes that have higher priority that are winning so I can see that the real green is coming from this local layout referenced a theme attribute which again we can chase down the values for so this is this is a bit like the chrome dev tools right where you can sort of investigate the whole resolution to figure out why or why is you know this text whatever font or color you're concerned about one other thing to point out is that this inspector is not just a static dump of the view hierarchy it is optionally live so if I go up in my running emulator click for example on the plant list you can see that it's now going to fetch all the surfaces and stay up to date so I can continue to see what's happening in the app and one really nice thing about that is that I can now drag this in 3d and see the full view stack here [Applause] and the really useful thing is look we have a full texture sitting back here and notice how we're showing you textures that are hidden right so this is not just a screen grab from the device we're getting all the the surfaces because this is running on Android ten so we had to actually add some support to do the value tracking and this bitmap fetching but now we can see that we have this texture hidden by this screen so this is overdraw this is bad and this tool makes it easy to track down those kinds of bugs as well as issues with clipping so that's the layout inspector right let's talk about the motion editor right so here I've created a very simple constraint layout and what I want to do is I want to Adam eight this so that it's a bit more lively one this layout shows up so what I do is I open up convert to motion layout this will migrate my layout into emotionally out plus create a scene file that's gonna store all the keyframes that we're about to create so the first thing I can do is to select the start state so we have start and end right I'll select the start state and then I'll start changing some of the constraints in the scene here so I'm gonna be deleting this to move the text to the top let's also attach this button to the bottom and now we've already created ourselves in animation so if I switch to the transition view and I hit play you can see it's now gonna start animating this and we can go and turn on showing paths so you can sort of see these lines here showing you how these widgets are gonna move so the next thing I can do is I can try to make this motion a bit more interesting so I don't want to lean your path for the label so I'm gonna now add a keyframe a position based keyframe on the textview and I'm gonna have the type beep relative to parent now let's move it about a hundred percent I just learned by the way that in Android we use one based percent which is doesn't make a lot of sense all right so that you can see now that the the the motion is a little bit more interesting right we can also fade in the button from the bottom so what I do then is I add a keyframe based on an attribute so we'll pick the Alpha and we'll put this on the button so now this is gonna fade in from about 0.

5 and we can change that to be let's start from completely transparent instead so now this button is kind of fade in and let's add some rotations because I like rotations so another key attribute and this time we're gonna be rotating the textview so rotation on alpha it starts out at 45 degrees I like to give it a bit more spin because rotations are cool so let's do 145 and we should also move it off-screen so it doesn't start in the middle and so to do that I will first select the state's textview and then we'll add bottom padding here say 300 or so alright let's see how this is starting to look so when I play okay we got some we got some motion [Applause] yeah so you can you can see that you can really go overboard you remember the web and the old days with the spinning logos on the webpage yeah don't go too far but with with some tasteful design you know you can you can really accomplish a lot with this tool so let me switch to a slightly more complex layout so what you see here is just start and end States right well that's just a default you can also create many other states so here I have a base state this is just a bunch of cards laid out with different colors I have this other state where all the cards are on top of each other and then there's a third state where they're all sort of off-screen up to the left and now you can sort of sequence the transition between all these different states exactly how you want them so we can have this transition we can have this transition we can have the sea I chose a state we can have this transition and let's check out the translation curves down here too so you can do really advanced things with this tool the last thing I want to highlight is that you can easily also create click and swipe handlers so when you do that emotionally out it's gonna add the code for you to basically add listeners so if I add a swipe handler for example the user can swipe and then motion that will scrub through the animation a bit like the quick settings pull down on Android you can do this through the tool which is pretty fantastic there is so much to show here that I don't have time to get into but the good news is if you stay in your seats for two or three more hours there's a whole talk on the from the design tools team that are going to show you sort of all the goodies that I couldn't show you today all right so a couple more quick things to show you first of all we have the in the resource manager we've updated the vector asset wizard with brand new clipart so the materials design website has many icons we've we've added them more importantly we now support all the different types so you can switch from for example filled icons to outline icons to even the 2-tone icons so hopefully you'll find that useful another thing we recently did for editing is we poured it all of our Android live templates to call them so if I for example want to add a logging tag into this class I just type log T hit tab this will create a logging tag for me based on the current file name right and more more importantly or more awesomely if you ask me log M this one will basically log the current method name with all the parameters right and if you want to you know a block structure and comment in between SBC tab you can type in your comment whatever so what you want to do is open up the live templates UI live templates settings and browse through all of these right to learn what tags you can type in with tab it'll save you a lot of time I think alright next I'm going to show you some stuff in the emulator so look it's still also run standalone so if I pull up the options Android now supports multiple displays and so we made it really easy to test multiple displays in the emulator all I have to do is go in and add additional displace I can tweak what kinds of density I want so it's suggesting this layout right here if I hit apply changes now you can see I have my emulator connected to multiple displace that I can then start interacting with yeah so definitely give that a try all right we've also made it easier to test locations so let's say I want to test motion let's say I have some sort of fitness app or whatever what I can do is say I want to navigate to the Googleplex and I'm gonna start from where we are right now which is Google building fp7 I think I can now save this as a route I'll call it demo save and now I can play this route and let's see what happens if I go into Google Maps here in my on my emulator if I click the where am I icon it's now supposed to be showing is that we're moving and we are [Applause] all right I think unless I forgot something I think that's my demo so now I'm gonna turn it back over to Jamal and I hope you enjoy studio 4 Oh all right so some really cool demos unfortunately have time to demo everything so I spend a few more let's talk about up some additional features relaunching instead of Android studio so first we're updating dynamic features so as you noted able to thembut features I have a module feature connected the main module but we're updating is that now you can have feature to feature dependencies so let's say I have a camera module and I want to add a video module to that so now you have a direct dependency it's a camera module without having a direct dependency on the app module so that's a cool feature of added for dynamic features another thing we added behind the scenes is actually improvements to the layout editor so actually what we did we took the rendering library so we have on the devices and put them directly in the ID so things like skia and is you are now available inside of Android studio and what that enables is two important things one is the performance so all the demos you saw you are using is that reactive performance that's there and to having higher fidelity accuracy so specifically things like improving text classification modes now supported having detailed shadows or having 3d perspective or having text path rendering are now available inside the layout editor so it's all happening behind the scenes and helping you to have a better experience inside of Android studio just as a quick update and we also did a big pass update on our templates for fragments so if any wizard that's there we updated all the templates for fragments so these fragments check that out as well inside of Android studio now big update before the Android emulator is something we're calling Canada's dual arm xe6 support so let's say if you have any C++ code today that had ARM arm support only you weren't able to use the x86 emulator because that didn't support the fast experience and so today we have a special version of the emulator supports both arm abis and x86 so I can run that legacy our C++ code on one emulator and have that fast x86 experience so we just released this on one version and we're really looking for your early feedback does make sure we have all the right use cases and would scale this out as we fir as you add more features to this going forward I also have an update on Chrome OS so aya we talked about having full first-class support for Chrome OS for Android studio and one plane plant for that is that if you wanted to bug your app or deploy your app it required you to have an external Android device or boots your boots your Chrome OS device into the developer mode now that's no longer needed you can do all you're into in development right inside of and right inside of the Chrome OS device so with the updating release of m80 of Chrome OS you can now do your development debugging and deploy the app right directly into Chrome OS to see it running inside of the remote laptop okay so we talked about a range of features that we're releasing things in the stable channel and also things in the bleeding edge features on the canary release channel now let me talk about the canary release channel of course it is it is bleeding edge right a lot of things are just in development and we're trying to explore things that are going on and so that in it's actually very lightly tested so we do recommend running both stable version of Android studio and the canary version of Android studio and you can do that as long as you have your Gradle plugin tagged toward the stable version of Android studio you're going to run both in parallel on the same project with no issues but for build attribution you'll need for oh yes and but as far as feedback goes we do encourage you to use canary because it's the best feedback channel for us if you file an issue or a bug on stable it's a little too late for us before I moved on to the next version so if you like the features you saw us a day or we give us feedback please use the canary channel for that feedback mechanism but even more importantly for us we're gonna think we're actually very coldly driven going back to my earlier point about project marble we set a new bar for ourselves for quality so some of the things we might see in canary may not make it into the initial version of stable because it may not be ready and that's okay because it'll make sure it's it's stable and as a high quality release before we make it out available to you in the stable release version okay so we talked about a range of things today and take her out a recap we talked about some things they're actually an Android studio three point six things like the multi display mode design tools updates and the intelligent 8 for 29 2010 dot 2 and then things like the jet pack composed motion editor support those are inside of Android studio 4.

0 which is currently available in canary so please check those out as you're trying out Android studio and with that please download Andres video canary to try these features out again I'm Jamal am tour in this is tour and thanks for coming recession [Music] [Applause] [Music] you [Music].

Source: https://zika-news.com

See More Android: https://zika-news.com/category/android/

Hãy bình luận đầu tiên

Để lại một phản hồi

Thư điện tử của bạn sẽ không được hiện thị công khai.


*