 Yeah. Okay. So as we were speaking, Gradle, so we moved from the and build system to Gradle. So today I'll be quickly talking about a few things that have changed. These are not specifically Android, Android changes, but more on the lines of what IntelliJ brings to Android and what the new grade build system means for Android developers. Okay. So though, so there have been a lot of tips and tricks which can save a lot of time for you. So I'll cover the best ones, which like, you know, are lesser known to users in general, will speak a little about live templates and then move on to Gradle as well. Okay. So I'll jump right into it. Yeah. So we always have this problem, you remember. So you want to debug something which keeps going on and on, but that is inside that statement being inside a for loop. Now, at you just see everything comes, but there is one particular one particular way value which is not being which is not being shown. So the regular way would be you would put a debug point, loop through run through it for like, whatever the loop run length is and finally get to it and then see it. So Android Studio has a nifty new feature called as conditional breakpoints. So what it lets you do is once you set a breakpoint on a particular thing, right click it and you can give it a condition as well. So in this case, as you see, only if I the value of I is equals to nine that the big point activates else it doesn't. So you just save a lot of time. You don't have to loop through like eight times before you go there. Okay. Paste from history. This one is something which I like very much. So you copy a ton of things. Then you like, you know, remember okay, that was something else. Then you go back, go copy again and come back. So what this does is keeps a when after you open the Android Studio, it keeps a track of all the content you have copied till then and you should be able to paste from history as well. So you can copy like five different things and you could paste the first thing which you copy. So no need to re go, go back, find it and copy it over again. As you can see this, it shows you those first five things. It even shows you what it has copied as well just so that you can confirm before you paste it. Okay. So most of the times you give a margin to something then realize, oh no, I need a padding here. So rather than manually doing it, this is something new which is you can select all the column wise and as this demo shows, you could just replace layout margin with padding and everything. All of them get replaced. Okay. Regular expressions. These these are things which are like, you know, the most painful thing to do. You write a regular expression, but you never know, will it work? Will it not work? You go online, you try doing 10 different sites, entering a regex, trying to see it matches, not matches. How would it fail? This, all of this can now be done here itself. So you enter a sample, you give it the regex, keep typing the sample, it will turn green or red based on whether it is matching out your regex or not. So the way you do it is you right click and say check regex, give it the regular expression, the sample and whatever sample you give should show up in green if it matches, else in red if it doesn't. Okay. So a ton of times you start getting code, then you realize, okay, this is getting too cumbersome and too heavy for this method and like, you know, I'm probably going to reuse this somewhere. The way you would use, you would create a new method, go copy paste it, remove it, then call everywhere, wherever you have had the same piece of code. What this lets you do is select the piece of code which you want, create it and allow it allows you to make a method out of it. It declares the puts all the implementation in a different method and also calls the method right away from there. So as you can see in this demo, which is, yeah, so four lines of code, give the method a name and press okay, though creates a different method for you. Multi selection. So if anybody of you have used sublime text, this is that feature which allows you to do multiple selection of all the variables with the same name and rename them in one go. So you have a variable X, you want to rename it at the end of the file into Y, just change one place and everywhere else it gets updated automatically. Okay, live templates. So this is, this has been around in even from Eclipse as well. You could go ahead and create custom code docs which you could use. Why today I'm speaking about live templates, what is new is the support which they have in Android Studio and Intel J basically. So the very for people who have no background water live template or a code block is. So basically, if you are reusing a ton of code over and over again in your application, what you do is you select that code and make a template out of it and just using a shortcut key, you can invoke that template. So in this case, if you see if I type ifn, it does a null check for me. If that is equals to null, then so this is a very simple thing. While this is nice, Intel J takes it a step forward wherein you could share these templates across teams, team members as well. So what we do in our company is we somebody creates a ton of classes, ton of methods or templates which people have to reuse over across teams and across cities. What you could do is just give them the XML files of an Intel J and they could just drop it in their Android Studio path and all of those templates works and all of those shortcut keys are something which is configurable and autocompletes as well. So if you can start typing, let's say you have something called as A, A, B, C for something, you start typing A, B, it will autocomplete as well for you. So that is one thing. How you do it is there is no keyboard shortcut apparently. The only way is preferences editor and then go to live templates. This is how it looks like there. You go in and you could so this is very powerful. If you are familiar with Groovy, you could go ahead and do a lot of things wherein you could pass in the parameters, read constructor parameters, return types, do things like typecasting, all of those things right away. So that is there. Moving on to Gradle. The bell system changed a lot of new features like product flavors and variants and configurations came in. I'll briefly talk about what these are. So product flavors. So how many of you people have two different code bases just to maintain a free version and a paid version? Yeah. So that pain goes away like no longer need to maintain two different code bases just for the sake of not showing ads or not being able to do packaging. What this lets you do is you could define a build product flavor saying this is the paid flavor and you could change the package name right away. So no more overwriting of the debug version and the release version, same EPK being overwritten. So you could now just say give it a package name and add whatever package name. So as I saw this is let's assume this the base package name is com.bms. There are some fields which are configurable like there is the ads field, there is the payments field and there is the promo field in this example. So if you see here in the paid version I say show ads should be false, skip payments is false and show promos is false as well. These are custom variables which we have defined at R and so based on these variables we decide at runtime whether or not we want to show people ads, show people payments, should the payment gateway call be skipped all together and all. So this is the paid version. I'll show you the free version as well. So as you can see I changed the package name to dot free after at the end and in this as well I have all of them by default. Yeah, so let's say you have a promo version, you get a dot promo at the package name. So now for all the free versions you maintain the same code base but three different APKs and three different installables are available to you. You say show ads true, skip payments true, show promos true. So all of these variables which you define here in your Gradle file are available to you in your code at runtime through a debug variable. So build debug variable should be able to give you this. So at the end of the day it is just a if check for you whether or not to check whether I'm supposed to show ads or not based on that show or hide that ad relevantly. Okay, so it goes a step ahead wherein not limited to just one set of variables which you can use each flavor you define can have a separate set of resources and Java files as well. So you could have different UI elements, you could hide a show elements, let's say one particular version of your build needs to show a particular color and a particular UI element but the other doesn't. So you could just do this is if you see you see a free package, a paid package and a promo package. There is a resource variable resource package inside each of them. So these need for this to work you'll need to name them the exact same way what you have. So if you have a red dot color something with a key called red in colors dot XML, you need to if you need to override them and something else you need to provide them the exact same names everywhere. So this works. Since you have separate package names as I mentioned like you know you could know more overwriting of the release version with the debug word. So a common problem with a lot of us what we used to face was we used to have the release versions on our phones but when somebody sent a debug build to us to test a new feature which was in ConLive, it would override the existing package, the package name because the package name was the same. So now we no longer have to do that debug will get a separate package itself by itself. Using this you could easily switch between test and production URLs as well. So like you know you don't need to actually go comment out the production URL then type in the test URL. You can maintain them separately and at runtime check which environment it is and then use that variable. A lot of people have used this for API keys as well. So with maps as an example, you have unlimited debug key and you have a release key as well. So that also can be configured so that you know which key to use when based on your build type at runtime. And again, you could easily remove the paid and promote to become phone and tablet versions as well. Since it you the entire resource folder and so this is in the example I have just shown you the resource folder. You have access to the Java files as well. So you can actually have two different Java files pointing to the same activity as well. Bill types, this is an extension to what we just spoke. You could have a release build, you could have a debug build, you could have a staging build. You could even change the suffix from here, the package name from here, but refer to do it in this way. A variant is what comes out with a combination of flavor and the type. So since in the example we saw we had like three flavors and three build types. So if you see promo debug, promo release, promo staging, paid release, paid debug and paid staging. So you could select whichever you want and then compile and build that particular APK for you. Okay, so that should be it. Any questions I would be happy to answer. So if you have so many dependent libraries, so is there any tip for improving the build time because whenever you switch between the builds, there is so much build time which Gradle takes, which was earlier very fast in Eclipse, if you see. So is there any tip on that like which can actually fasten your build time? I don't think that could be possible because Gradle will still have to look at your dependencies and build it because like as an irony, you can't have two buildout Gradles for one for test and one for production. So I still don't see that how we could be able to do that. The only way I have achieved, so if you have split up your app into architecture thing like an MVVM or MVP kind of thing where you have separate modules, separate packages, buildout Gradle allows you to do things like you could define them separately as well. So I could say these are the modules which are common. Okay, so when you build just the app and if your app does not depend on the common dependencies at that point of time, then just the app dependencies will get picked. So rather than in your app's buildout Gradle, you have like 10, 20 different this, which are all because like, you know, some module is depending on them. But if let's say you're not even trying to build that module for that particular run cycle, that what you would do is upgrade them out like that and just the app needed ones will compile. Okay. Hi. Quite a similar question, actually. Let's say you have an X number of files which are actually not dependent on payment or pay or any feature like that. And how would you just separate them out and, you know, you don't have to copy them on each and every folder or something like that. So you mean, let's say you have something called as payments which you don't want in the free version at all, correct? No, I mean, let's say you have some some part of your files that are actually common to all of all three of them. All three of them. Yeah. And you don't have to copy them every time you build some place you don't have to copy every other time. So these folders which you create separately will only have those Java files and resource files which need to change. Everything else which is common goes in the main folder itself as your regular app. So that way your main will remain the same. Only files which you need to change. You just need to take care. Let's say you have payments activity. If it is a different implementation in the free and the paid version, you just need to copy the payments activity to those two. Everything else should remain the same and work fine. So you're saying that payment activity should be there in paid and free paid and free and not in the main version. Okay, but in the main one, what files would you import them? I mean, because so package is is different that all of that build Gradle will take care of you when you choose which version to build across. Yeah, when you choose here, which version to you are trying to run, he will automatically pick those folders being active and do the important runtime for you. So you don't need to bother. Okay, thanks. So I have to cut Q&A again. That's about it. Yeah. So any questions if you still have, you can always come and talk to me. There's a launch downstairs with so far. Again, you can take the questions there. This is the last talk before lunch.