 I don't know what my name is but I'm an Android developer just for the basic thing though. And I know a few of you are lost like what was the project Mickey and what was the activity, what is like intent, what is drawable, what is RES folder, what is layout. So how many of you are familiar with basic Android terminology like what is an activity, who knows like what is an activity, nobody. So okay I think what we will do is like I'm going to run through a very few basic slides. I'm just like quickly going to run through them like for five or ten minutes. I'm going to explain what activity is, what intent is, like what is layout, why do you need them and then then we're going to create a very simple application project and then we're going to run that. But before that because in my last workshop people have experience that they were not able to set up the Android studio so is there anyone who is not able to launch Android studio or facing any error with that. So everybody is ready with Android studio, okay cool. So starting with my boring presentation it's really like what is Android, some people call it like it's an operating system, some people call it like it's a mobile platform, it's up to you whatever you call. But basically it's not an operating system, Linux is the operating system and it's just a stack of software on top of Linux. And yeah there are millions of mobile devices which use Android. Now why Android? Some people are like oh there's iOS development, there's Android development. Now why only Android development? These are a few reasons because definitely there are more jobs for Android. So I think choosing Android is more intelligent decision. Now how Android came into picture? It was initially developed by Android Inc but Google bought it in 2005 and then the first commercial Android device came in September 2018, I guess it was by Motorola or STC, any one of these. And then they have been releasing multiple versions of Android software and the last was released in December 2017 which was Android 8.1 Oreo. What are different kind of Android devices? Like you have Android VR, you have Android TV, then you have Android Mobile of course and then Android Auto and they have been versioning the Android operating system based on like sweet desserts. So it's like it started with Cupcake and Nogurt and the last was Oreo. Now how do you get Android apps? So Google Play, this is how it looks like on the right hand side and Google Play is the market for Android apps. This is just like very basic knowledge like what Android is, where does it come from and then Android development like yeah, this is a little technical like what do you need for Android development? So for every development you need a language, right? So I'm sure like everybody is familiar with some basic programming, right? So yeah, for this we need Java. Java is like mandatory, without Java you cannot complete Android development. And Kotlin, Google in 2017 IO, they announced that Kotlin can officially be used as a programming language for Android. So nowadays like almost all the organizations are migrating their Java projects to Kotlin. Even like I work for Grab, even Grab is doing that. And how do you test Android applications? Like you can use your phone, you can use emulator, emulator, yeah, it sucks like we just saw. And Jenny Motions and Blue Stack and there are many more open sourced Android devices available for computers as well. Now, as I said that somebody said, like some people say it's an operating system and some people say it's a stack of software. So this is just to give you an overview like what stack of software are involved in Android. So a typical Android phone and a typical Android software stack looks like this. So in the base we have Linux where we will have like kernel management, thread management, multi-threading and all the process management. On top of that we have HCL which is like hardware abstraction layer which is like in order to access your Bluetooth, in order to access your camera, like access all the hardware parts of your phone. And then on top of that we have two parts, one is Android Runtime and another one is Native Library. Android Runtime is basically whatever application you will write in Android will be run by Android Runtime. Native libraries it's like Android Runtime, part of Android Runtime is written in native like C or C++. That's why we have the support here. On top of that we have Android Framework. Android Framework is basically what is used to develop Android application. Like for example, activity manager, resource manager, notification manager. Like how do you actually access the Android APIs in Android Studio? So this is where Android Framework comes into a picture and on top of that any application, like whether it's system application, SMS, contacts or like your personalized applications. Now in order to develop an application what do you need? You need Android Studio. I missed your unit Java as well, Java JDK8. So but yeah, Android Studio is the least that you need. Now here comes the actual part like we talked about activity and something and something and something. So these are the main five components and Android application is comprised of. Okay, first is activity. So as Yulin said like activity it's like what you see on screen, okay? You're like in Splitbilla you were seeing okay it was saying like okay, capture the image and then do something. So one single screen represents an activity in Android terminology. Then we have intent. So I prefer to call it like intent comes from intention. So in Android whenever you want to say like I want to perform this task. So how do you tell Android that you want to perform this task? You create an intent for that. There are some APIs to create but and they are called intent. Service is something like okay now no Android application is complete without network connections, right? Like even Facebook, in Facebook you download images. You download like videos and you do a lot of operations. But what happens is like you're scrolling your timeline and your images are also getting loaded, right? So you're performing multiple things. For that service comes into a picture. Like service is mainly used to perform things in the background. Like you will not want that on Facebook in timeline. You can only either download or scroll, right? You won't use it to perform both the actions at once. So that's where the service comes into a picture whenever you want to perform some background operation. Content provider, it's a little complex I would say and we don't need it for today's session though. But content provider is basically to share the content between applications. Like for example, in Facebook when you say maybe you want to call or maybe in Instagram or like in any app, WhatsApp, okay? Let's take an example of WhatsApp. You say you want to send a new message to some contact, okay? So you click on plus or maybe you want to share your contact to somebody else. So you click on plus and share contact and it displays all the contact list to you, right? So that means that contact system application have defined a content provider. That means they have defined a mechanism by which they can share the data with other application. Otherwise you cannot share the data that way. So this is content provider and then broadcast receiver, it's very simple. Like when we have like fire alarms or something, we broadcast things so that everybody can listen to what's happening in surrounding. So your application, there are a set of broadcasts that system raise. So your application can listen to all those broadcasts and they can register a receiver. Like for example, okay, when you're listening to a music, like maybe some MP3 application, when your battery is low, your music stops. So how does your MP3 application knows like your battery is low? So basically that application has registered itself with a broadcast that whenever system will raise a broadcast that battery is low, it will act on it. So they are not limited, I would say actually you can define your own broadcast as well, which like one application raise to another application. But there are set of predefined broadcast which Android system raises. So that's what the broadcast receiver is. Does anybody have any doubt in what each component does? We will be using that in Android Studio project. So I wanna make sure that at least you have a basic idea. So when I say activity in Android Studio, I assume that everybody is aware of what activity is. Okay, this is just like the additional slide. How do you learn more Android? So Android documentation developers.android.com, this is the best documentation that you can ever have. So they have simple projects, they have everything. Like whenever you have doubt, you can just say Google, how to create a button, how to create an activity. And the first link that you will get is from developers.android.com. So make sure to check that out. There are so many Slack groups. Actually there are Slack groups from Google Android developers as well. Like who actually developed Android? You can join them. There are free code camp, medium blogs. There are Android, code hub, something like that. So there are a lot of medium posters as well. Yeah, Udemy courses. And the last two are the Slack channels that I talked about. I think, yeah, enough talk, let's go. So maybe, does anybody have any doubt in that, no? Is anybody lost? No. OK, then I think we can start. Maybe we all can open our Android Studio now. Yeah, I assume everybody has their Android Studio set up. So I'm going to move past a little faster from this thing. So everybody can see this screen. Maybe you can click on start a new Android Studio project. We'll start from the scratch. Yeah, OK, what kind of app are we making? Do you have something in mind that you want to create? Very basic. Alarm? But alarm will require more Android API collections to be used rather than basic one. So I was thinking maybe like last time we created that login kind of thing, right? But today what we can do, like when I learned programming, we always used to create first program add two numbers, right? This is the basic program that we do. So maybe today what we can do is we can create two input fields, and we'll enter two number, and then we'll have a button. And on click of that button, we'll display what is the sum. And if we are able to do that in time, then we'll move on to how to open another activity from one activity, like you'll explain from loading, like from welcome to loading, from loading to added activity, how to do that. You can name your application anything that you want. I'll name it as WW code app. Company domain, you can ignore project location. It's basically where it will land up in your computer. Package name, either you can leave it like this, but package name for Android is always small case letters and follows this pattern, like login, dot, something, dot, something, dot. In general, if you will see in Play Store, things are like com.app.www code app. This is like a general procedure that people follow. No hard and fast rule. It's just that it has to be small case letters. When you're done, you can say, see, as you can see, they have already like included, include code in support and C++, but today we'll be doing in Java. So say next, this screen will ask you, because we have seen that there are different kinds of Android devices like phone, where TV, Android Auto, but today we are going to create phone and tablet app. So let it be checked like the very first check box. Second one is API. As I said that Android has released a lot of versions and each version comes with an API, like a different set of APIs are included. Everybody is familiar with API term, right? What API is? Yeah, so in each version, we have different set of APIs. This is the minimum API. That means your application will not run on any phone which has lower Android version than this. So API 15, which is Ice Cream Sandwich, I think it covers a lot of Android market. So we can let it be like this and say next. It's very supportive. Like Android Studio is like seriously smart enough to do a lot of things. Okay, it says what kind of application do you wanna create? Like what should your first screen or maybe any screens should look like this? Now why to work hard when things are already available to us? So maybe I can just say empty activity will decide what kind of activity will it look like. Just say next. It has named that main activity. So it's again the Java naming convention that it follows camel case, like starts with capital error than smaller than second starts with capital error and then small case. So this will be the activity name. You can name it anything that you want. It's not necessarily main activity. And another one is layout name. Now what is a layout? We said that activity is a screen which we see, right? Now what do you see in an activity is defined by layout? Like button, edit text and like toast and list of views or something. So that will be defined by layout and our layout name is activity underscore main. It's a good naming convention and we are good people. We follow the convention. So let it be like this and say finish. If you're running Android Studio for the first time, it might take a little longer in order to set up the dependencies. This updating rule, this is the slow-witted. Updating, which like updating to what? It depends what kind of updates. Like for example, with Mac, Mac OS high Sierra, it really slows down your Mac. So it's recommended that you don't update to that. So yeah, it definitely depends on like, it definitely matters what kind of patches are involved in that. So that's a good system. Yeah? So just lay out this, like your control and then your activities. And all control, I'm not sure what do you mean by control here but layout is like visual appearance. Like you see buttons. Like for example, on Facebook login page, you see username and password and then button, right? So layout is an XML based file which will define those buttons and those edit text. So yeah, so as Yulin said, that it's an MVC model view controller kind of base. So model view controller, it's like one type of architectural pattern that is used. There are so many. So there are many different roles. Yes, yes, yes. Everybody can see this, fine? Cool. Shall we, okay. Because not all of us are familiar with Android Studio as well. So just a very quick overview. This is how a typical Android Studio file and the view looks like. What are other options in Android Studio that you can explore? This left hand side, this is your project structure view. And when you click on Android, so you see different kinds of view that you can get into, like project. If you get into project, it will look like this. If you click on packages, it will only show what kind of packages are there. If you click on Android, it will show you what all files Android is concerned about. I mean, we typically keep project view so that it's clear, like, okay, there's an app module, there's something, okay. These small, small directories, like these small, small folders, they are called modules. And here your Java file, your XML file, okay. This is our Java file. And this is our XML file, which we were talking about. You have two views in that one is design, in which you can drag and drop and create views. And another one is text, like you can define or you can code all by yourself if you don't like drag and drop. And on the right hand side, you can see the preview of what your layout looks like. So right now, there's nothing in there. It's all empty. If you go to app and then SRC and then main, so like it automatically created few directories, which is like SRC, then Android test and test. So test and Android test are for like basic unit testing and instrumentation testing, which we will not be focusing for today. So you can just ignore them. And then main, in main, we have Java and RES. Java, we just had a look that main activity dot Java. So it will have all Java files inside it. RES will have all the layout files, okay. Like if you look at layout, we will see activity underscore main dot XML. There's nothing in there, so I'm gonna close the preview. So we have a lot more option to call. Guys, whenever there is a confusion, please let me know. Or if I'm going too fast, let me know. Or if I'm going too slow, then also let me know. My NDK is not clear. NDK? Yeah, so I'm just like. Okay. Your system will start running towards the end of the workshop like before. Okay. So as we said, yeah. Project sync failed? Yeah, okay. What's the error you see? Okay. But what is the error that you are seeing? Sync failed. But there should be some message along with it. Why did it fail? Yes, yes. Rightly said. Whenever you see some Gradle build error, it will show you what kind of error is this and a link to fix that. Just click on it. In case you might be missing some dependencies which is required for Android project. Okay. Cool. So as we discussed that, we will create two input boxes and one button to add the numbers and turn into those input boxes. Now input box, how do we create input box? So there is definitely an API for that, which is like edit text, like the text which can be edited. See how smart is it? Like you just have to start typing and the suggestion that it gives, you just click on that. And what is the width and height? Like it's like, as the name says, what kind of width and height it will be covering on main screen. So width, I would say, okay, match parent. Match parent is the like. Match parent is like whatever the screen size is. It will cover up that. Height, I don't wanna do height match parent because I want to add more views to that, to the screen. So right now you can just randomly say, let's say 50 DP. Now what is DP? DP is like density per pixel. Like each screen, it consists of pixels. And density is like in one particular area of that, how many pixels are there? So I just say 50 DP, okay. Now I'm gonna assign it an ID as well. Why ID? This is same like right now, in case if I want to address someone of you, I have to know your name, right? Then only I can address. I cannot randomly say oh this and that. So in order for Android system to know which edit text is this or for us to maybe perform functionalities on particular input boxes, we need to know what kind of input box we are dealing with. So I'm gonna assign ID, say like first edit text. And now we can see preview. As we can see in preview, we see one edit text. We can add hint as well, like enter first number. What should be done of the layout? Yeah, layout width. I kept it as match parent. As I said, like match parent is like, it will cover the full screen size. But let's say in case if you don't want that, you can define some 100 DP or maybe you can define like 50 DP, 60 DP, something like that. Or because we are dealing with a very basic layout, Android supports very different kind of layout. Like in which you place layouts in position. Like for example, I say, you should sit next to some other person, rather than saying, oh, you should sit at that place. Like I reference two views. But we are dealing with a very simple layout. So you can like, instead of match parent, I can say 100 DP. For now, let's go with the basic thing. Like, okay, it's already constant layout. And then let it be match parent. We can beautify our layout afterwards. Like for example, right now, we can make the functionality work. Is there a file for constant layout? Constant layout, it's an API from Android. There's no file like, it's android.support. And if you want to go to any API details, like for example, android.support.constantLayout, it's an Android API. You just like command or click, or I guess control or click in Windows. You just click there and it will take you what kind of layout is it? Is it your choice or the ID is format and like that? Okay, it's completely up to your choice. It's completely up to your choice. Like you can name it one, two, three, four, five, six. But it's that when the project is really big. For example, again, consider WhatsApp or Facebook. Like there's so many views, so many edit them in your code. You should be, like when you say first edit text, you should be thinking about, okay, it should be the first edit text in the layout. If you name it like one, two, three, four. After a while, you will not realize what does one, two, three, four means. So it's completely up to you. You can. It's like your identity. Yeah, it's a identifier for that view. Whatever my person. No, no, it's okay. Yeah, yeah, tell me. What are you trying to write? Tell me. I'll try to write that here. Please do like first text in the text message. Okay. It cannot be like this with spaces. But she's not writing with the add. No, you have to follow this pattern. Okay. You delete this and then say you start writing ID and then click on the very first link and then you again see the suggestion, right? Add plus ID will create a new ID. So you have to do this. Okay, so it's like the format. Yeah, it's like the format that you have to follow. Yes. And those who have created first input box, they can just copy it and paste it. But it will show you an error like, okay, first name edit already exists. So you can just say, yes, second is enough. Now we don't see it here, right? Okay, I think the base we can do is we can, I'm sorry for this, but we can replace this with relative layout or let's say very basic linear layout. Because constant layout is a little complex layout. Okay, now it will throw you an error like, okay, linear means you will add views linearly. Now it can mean horizontally or vertically. That's why it's throwing me an error like, okay, what kind of linear layout you want to use? So you say orientation and I want to add them vertically. What is the difference between like a horizontal? If I say horizontal, that will be like side by side. And if I say vertical, that means one below the other. Yeah, you can remove constant layout and type it with linear layout. Those who have already done that maybe just can explore like because it's auto suggestion is quite like powerful and at Android Studio. So you can just like Android or something. Now, what all you can do? What have anything does or something? You can just explore it if you're getting bored. Is it coming side by side? You have to define orientation as vertical. Have you defined orientation vertical? Oh, sidebar, it's here like on the right hand side you see preview. You click here on the corner. Do you see preview? Yeah, just click there, okay? So now we can see two input boxes. I'll add, now I'll add button. Button is very simple, like, okay, button is button. Again width is okay, let's say match parent. Height is let's say 50 DP and we'll give button a name, okay, add button. And text is like what kind of text do we wanna show on that button? I wanna say add. So as you can see, like, you keep on writing and it will keep on displaying on the right hand side. Yes, so yeah, it's looking very ugly, right? Right? Yeah, it is, it is. So let's give some space. Space is very much needed in life. So, okay, so let's give space between number one and number two, and yeah, and let's give a space between number one and number two and then number two and add as well, okay? And how to give space, it's a linear layout. That means views are placed linearly. So you can just say margin top, like how much it should space from the top view. You can just say this and I'm gonna say, like, maybe 20 DP, as we can see the difference there. And for button as well, I'll say margin top and I'll say 20 DP. Does it look beautiful now? Better, right? Do you wanna add color as well? I think we should add color. RGB, okay, 0, 0, 0, 0, 0. No, I like red. No. Shall we move next? Okay, okay, cool. This margin top, highlighted one. So margin top, right, I think, like, one's one on top of the other. On top of the other? Well, if it's linear layout, it will never come on top of the other. It will be, like, sticking to each other. That's it, like, number one, number two, and then button. It cannot come, it cannot cover the other view. But if it's relative layout, in that case, it can cover other views. Relative layout is basically meant for, like, we have three views. So we specify, okay, this view should be shown in relation to this view. And if you do not specify any relation, they will cover each other. So that's why I chose, like, the simpler layout, like, linear layout. I don't need to define relations, like, it's already, like, linear relation. Yeah. Then? Yeah. What happened? The arrangement has not happened properly. Yeah, sometimes, actually, sometimes because of the memory issue, how much RAM do you have? 8, 16? So actually, it happens because it needs a lot of RAM and, like, memory management. So sometimes, that doesn't happen. So it's okay. If your code looks like this, your screen will look like this only, even if it doesn't run around the right-hand side. We'll see in the emulator in the next. Now, shall we move next? Anybody stuck anywhere? You said... As vertical. No need to write full thing, just start writing or O-R-I-E-N, and it will suggest you in this, then just hit enter and... Is there some confusion? There are, it's in red color, something is wrong with it. Yes, if it's in red color, something is wrong in it. Okay. Let's say I remove this. It becomes red in color, right? That's what you mean? Red color. Yeah. Right now it's red color, right? It's yellow. Ah. No, this... Oh, you mean to say this whole layout isn't... Okay, let me try. Now it's not red. How come it's red? The first one, what do you think it is? If it's like this, then you can hover on it and it will tell you wrong orientation, no orientation specified, then we'll specify orientation. Color? I haven't given any color. But if you want to give color, let's say to button, like what should be, right now it's gray. If you want to give color, you just say, oh, background. What should be the background color? Then it takes like hex of the color. So you can say just hash and then like RGB, FF something. Like if it's red, then FF000. So it will be red. Is it looking like this for you? Like... Okay. Done? Cool. Shall we move next? Okay. Now we know that we have designed a layout. Now, what do we do? We have to actually perform the functionality, like take the number from first input box, second input box. And when I click on add, it should add. But I think we should add a text view as well so that we can display what is the sum. So edit text is text which can be edited and text view is something just for display. Like just set the text and it will display. If you click on it, or if you do something with it, nothing will happen. So again, I'll say match parent and I'll again say, let's say 50 DP and I'll give margin. I'm gonna give a lot of margin this time. Here I will display the result. In case if I set text here, it should, okay. Okay, don't worry about all these things for now. Yeah, just create a text view and let's give it an identifier and we'll say result text view. Why am I following this particular convention as like camel case like small r and then capital T in capital way? It's like standard Java naming convention. So basically this is what I'm gonna do. Like we'll enter one number here, we'll enter another number here and then when I click here, it should display the sum here. Right now on right-hand side, you don't see like you see button and first input box and second input box, but no text because there's nothing set on it until you set some text and something like, what will it display? It will be just blank. Done. Cool. So now we are done with the design. Now we'll go to main activity like the Java file where we will define actions like what will happen on what. This statement set content view which is like already there from Android Studio. This says that okay, when this screen is shown to the user, this layout should be inflated and in this layout we know what we have like two input boxes, one button and something. Now comes the main part. We have created a button and what we wanna do is on click of that button, we wanna take both the input numbers and add it and set on the text view that we have designed. So we have to have a button. Now it will say okay, import that button. So you just say import class. It's already an API from Android. This is like in any programming language creating a variable of a specific type. So I'm creating a variable of type button. I'm gonna name it as add button and we have given an identifier to this button, right? So how do we find that identifier? So there's a function for that which is like find view by ID. Yeah, just raise the question, you can just shout it out. Build tools, did you click on it and install them? So when you see this find view by ID, you just click here and you try to find that identifier and how to find that identifier you just try to write R.R file is the generated file by Android system which keeps a track of all the identifiers. So whenever you wanna find out, like for example, in this class, if I maintain a register or maybe a Excel sheet which contains all of your names. So if I want to look up to something, I'll go to that Excel sheet and start searching for it. It's this similar like analogy here. So R is that register or that Excel sheet which contains all the identifiers. So you just say R. Now what did we assign it to ID? So you say ID and you can already see the possible IDs that is there. And seriously, this is that smart enough that it's showing add button as the first suggestion. So you just say add button and because it's Java, we have to add semicolon in the end. You have to import it if it's not imported. Just click on it and it will say import. For those like, for those whom button is not imported, it will give you an error like this, right? Red button and this, but when you hover over it, it says like in Mac, it's like it's just command and enter. When it was red, from today, it's a command and enter. So what does it mean? Alt and enter? So basically what I just did is like, it's a shortcut to import something. Like earlier it was like, for example, this statement is not there and it will throw me an error, cannot resolve button. Like it says that this is not imported in this class. So I just go there and I say command and enter. So it will just, it's a shortcut for importing. I have been using shortcuts that much that I forgot how to do it manually. Now, yeah, and then say import class. Are you able to import button now? May I check, what does it say there? Yeah, yeah, okay, we'll come to this error, like what is this error? This is a different error than import. Okay, those of you who are getting this error like a red line below this, this is because this returns a view. Now, we are trying to assign this view into a button. So we need to explicitly typecast it. So those who are getting that error just type, sorry, just typecast it with button. Like, okay, you are returning me a view but it should look like button. It should remove your error. It removed, right? Yeah, clear? Cool. So now next, what are we gonna do is we were about to define an action on click of this button. Simple enough, say add button because now we have this variable which represents a button and say set on, start writing this, set on click. This is how we define a click action on anything. You'll see the first suggestion is set on click listener. Now we wanna define a new action. So how do we define a new action? You start writing new, which is new and it's a on click action. You start writing on click and it will throw you a suggestion, right? Yeah, just hit enter. It will auto-complete it for you. So basically this is kind of, we have created a new on click action and here we have to, like I'm just adding a comment, like define what do we want to do. Like we wanna take number from input box one and two and then add them and then set it to the text view. Like this is generally a comment which will never get executed by Android. This is just for the understanding purpose. Now, what did we define input box as edit text, right? So in order to get the number from edit text, we need to again create variables of edit text. So what I'm gonna do is edit text and I'm gonna name first num edit text. I'm gonna again say find view by id, r dot id dot this time. Similar way I will create another variable. So I'm just gonna copy and paste it so that I don't have to write it. I'm gonna name it as second and here as well I'm gonna name it as second. Those who are using Mac, you can just say command D, this command D. So like it will just copy the above line. Simple. We created two variables. Now what do we wanna do? We wanna take numbers from both the variables, okay. Int because we wanna add them. So ultimately it's just like int and Java. So I'll say num one which should be first number edit text dot, okay. Edit text has a function which is like get text. What it will return is it's a input box, right? So whatever you will write in there, this method will return me whatever has been written in that input box. Now it will throw you an error because this if you go here as I said, like you can go to the definitions of this. Get text returns editable, which is ultimately a string type, but we are trying to assign a string to number which is like integer. So definitely it will throw this error. So this is like I'm gonna parse it. This is Java convention. This is like typical Java. What happened? Pass, not parse, okay. Get text is editable. So we have to convert it to string. Command D, now not here. Which is like I'm gonna take the second number as well. So we have number one and number two. Just copy paste that line and rename the variables. Once you have this, third one is pretty like final result, okay. We'll say result equal to num one plus num two. This is like a simple Java statement. Let me know if anybody is not following what we are doing right now. Anybody has any doubt in why did we do integer.pass and now, okay cool. So now we have the result. Now what is the final step? We have to show that result into the text view that we have created. So we're gonna again do, we're gonna create a variable, which is like text view. We're gonna name it as result text view. I'm gonna say find view by id. And once you have text view with you, what do you wanna do? You wanna just set the result to the text view. So you wanna say result text view dot set text. There's a method called set text. You just say set text and what do you wanna show? You wanna show result on that. For those who are seeing the error, like again the red line here, it might throw an error because result is an integer. And if you go to set text, it takes string resource. You might see my definition a little bit different because I have enabled all the Kotlin support and different supports in my Android Studio. So basically set text takes a string and we are trying to set integer. It might throw an exception. Not might, it will throw an exception. So the easiest way for converting an integer to a string is like concatenate it with double quotes. A string is always written in this form like double quotes and something. So if you have number, you just concatenate that with string, it will give you a string. Take your time because functionality-wise we are done. The next step is to launch the application. Any doubts? Yeah? Okay, layout, okay. For example, in your screen, I have defined that which should be match parent or like maybe let's say if it was 30dp or 100dp. So layout gravity is where should the layout should be placed. Like for example, if you say layout gravity should be center horizontal, okay? So that means let's say if your layout has a width of 100dp, it will cover the center 100dp, not like the left or the right or something. The layout would be placed in center of the screen like center horizontally. But apart from that, when you say Android gravity, gravity is the content inside that layout. Like for example, if you have a text view and it has a width of 100dp, okay? So inside the screen, okay? Let's say this, I'll explain it here. Instead of match parent, I'll say 150dp. So see right now it is on the left-hand side, right? Let's try to assign it gravity. Come on. And I say center horizontal. It's in there. But now if you see, I'll set some text to it. Let's say result text. The text itself is on the left-hand side, right? If I say only gravity, not the layout gravity. If I say text, now the text is in center horizontal. So one is in respect of the full layout and the other one like Android call and gravity is in respect of the content inside the layout. Like if you say center vertically. So it's on the left but vertically. If you say center, so it will be like center horizontal and vertical. So yeah, let's say if you say, if you remove this. So the layout will come towards the left because we haven't given any layout gravity but we have given content gravity which is center. So it will be in the center, clear? Cool, okay. Done, let's, okay. Now try to run it but I don't have any emulator running. So we'll go to tools in case if you haven't created any emulator and we'll go to Android tools and Android and AVD manager. AVD manager is Android virtual device manager. I'm gonna delete this so that, okay. So if you haven't created any virtual device yet, your screen should look like this, okay. Now I'm gonna create a new virtual device. Pick your, like I like pixel. So I'll create pixel and say next. It's gonna ask you what kind of Android device do you wanna simulate like you wanna, based on API level. In case if you do not have any Android virtual device, API is downloaded, you need to, like for example, Lollipop which is 22. It says download it. It's virtual image is not downloaded yet. So you click on download and then it will become like this so that you can select and create an Android virtual device with that particular API level. I'm gonna create it with Marshmallow which is like 23 and then say, or maybe Nougat. And say next and then say finish. Nothing else. Virtual device is created. Once you have created that then you can, when you will click here, you can see virtual devices to run with. In case if you have Android phone with you and USB cable, we can launch in your phone as well. But let's first try with Emulator because launching in your personal phone is quite easy. You select this and you say okay. Yeah. We'll come to that but first let's try to run that in Emulator. That will be faster. Launching it in your own device will be faster than this. But I forgot your name. Reviti. Now you are a proficient Android developer. Why don't you help out other people and whatever problem they are facing? Yes. Of course. Last time also you developed an application. Yeah. From constraint to linear. Earlier it was constraint layout. So constraint layout is a bit complex in which you have to define different constraints in respect to the screen like where should it land, what should be the X position, what should be the Y position. Yeah, yeah. So I like simplified it and I put like linear layout here. Just put linear layout here. And if it shows you an error then you have to define orientation as well here. I'm trying to, you know, launch in your phone. Did you have downloaded images like Android images? I've downloaded before. Okay, we'll go again. Android and every manager. Okay, I'm gonna delete this. And I'm gonna delete this as well. So if we have any images inside the mill, it will have this. Yeah, yeah, yeah. It should show. So you say, let's say okay. Okay, next was five. Next. Actually it depends what kind of platform does it use. Okay, let's try it. See, okay, recommend it. Okay, we'll use this. See next, set finish. I did click on finish. Okay, let's try to run this if it's running. Cannot launch. Okay, I'm gonna show advanced settings. It's not like, do you have Android phone with you? Yeah. Can you give me cable? Yep. Can you give me cable and instead of wasting our time in fixing this issue, we'll rather, can you open your phone and go to? I have the debug mode. You have the debug, debugable mode. Yeah, then just launch it in your phone. Text wheel. Yeah, there's this text wheel, which is here. I'm gonna display result over here, like what is the sum of two input numbers. And those who are able to launch the application, just go to your application and say, maybe you wanna try to add number and then say, oh, it's too small. So I'm gonna increase the text size a bit. I'm gonna say, let it be 30 SP. Okay, what is DP? What is SP? SP is like scale independent. So whenever you define like text sizes, you define that in SP. Whenever you define like dimensions, like margin and all these things, you define that in DP. Why SP? Because it should be dependent on what you set your font size in your phone. So in Android phone, you can change your font size. Like it should be large, it should be medium or something. So when you say, if you set DP here, it will not change when you change the font size in your phone. So it has to be SP. Okay, now 30, like we can see here, let's try to add some text. This big it will look, we can actually, and then we can set the gravity as well that it should be center horizontal. This is just beautification. So right now don't worry about it, but you can add text size because it was looking really small. And when you do this, let's say I'm gonna try just to make sure that it's not hard coded and it actually works. So 10, 10, it's your display. Oh, I haven't run the app again. So I'm just running the app again. Okay, now I'll say 10 and 10 and then say add 20. Yay! So we learned how to sum two numbers today. Back to the basics of programming. Clear enough? Is anybody facing any problem with launching the application and then like something is not shown or maybe throwing some exception or some crashing? Yeah, I was thinking that if everybody's able to do this, then maybe we can do a quick like five minutes to like how to debug when your app runs into an error. That's really important because most of the time things doesn't work in first chance. I'm just gonna make it crash one second. It crashed. Let's forget about why did it crash, but somehow it crashed. And when I enter 10 and 10, I'll do it again to see what does crash means. Crash means like you'll see this kind of dialogue when app crashes. This is a common terminology in Android development. When you say add, it will say it keeps stopping or unfortunately it has stopped, something like this. So somehow it crashed now. Now, when did it crash? When I actually clicked on add, right? So how to debug these kind of things? Now I know that something wrong happened in on click because by the time I enter two numbers, nothing happened. But when I clicked on add, it crashed. So in your Android studio on this where the line numbers are displayed, you just click, it's called a break point. Now you close your app again and okay, got it. Where is our application? WW code app. Now you know that app crashes when you click on add. By this point we are safe. Now I'm gonna attach a debugger to this. Debugger means it will take me step by step into what is happening. So if you can see this Android debugger, this option, you just click here. And it will ask you like, okay, what do you wanna debug? So it will show your app if your app is running. And then you say, okay. Sometimes it may take a while to attach the debugger. Okay, it's attached. When it's attached, you'll see this kind of message that connected to the target. And you'll see a checkbox here. This checkbox means that this code will be executed if app is running, not the checkbox like the tick. Okay, now you click add and it comes here because we knew that this is the on click function. Now this is how the debugger mode looks like in Android. This is like what all methods it has been through whether it's Android internal calls. Like for example, perform click. This is from Android view. So this is like internal to Android. So we see that as well. Then it came to on click main activity. Okay, here you can see the variables values that you have created. Like for example, okay. And in run, you see step over, step into, if you are familiar with like programming any debugging, step over means go to the next step. Do not go into details of this step. Step into means just go into the details of the particular step and step out means if you have gone into the details of the step then come out of that step. I suggest that you remember that step over is F8, step into is F7. So, okay, we don't wanna go into details, find view by ID because we knew that it was working. So we don't wanna go into details. So I'm just gonna say F8 and it goes to the next line. Even in variables, you can see now first name edit text contains some edit text. You don't wanna know like it's a huge detail like, okay, what it like text helper and something and something. You don't wanna go there. Now you say F8 again. So now we have two variables which are already in memory which is like first number edit text and second number edit text. Okay, everything is fine until here. If it passes through every step that means things are working fine by now. Now you see num1 is 10 because we have already entered 10 into this. Okay, so this step is also fine. Again F8, num2 is 10. So that means that step is also fine. F8, oh the result is 20. So that means even this step is completely fine. There is nothing wrong with this step. F8, again. So now you see result text view also contains some information about Android view. So that means this step was also fine. Now we are on the last step. And if you do F8 here, then you'll go into some Android internal details call and that will happen only if your app did not behave the expected way. If it would have behaved the expected way, it would have come out of that on click function but it didn't and it went something here like then you'll see some random messages logging null and this and that. So that means that statement was the culprit. Okay, even if you say okay and you go to log cat, do you see log cat here? You click here. When your app crashes, I'm just gonna enlarge it. I hope everybody's able to see this. When your app crashes in general, you will see a fatal exception in log cat which will explain what happened, like what wrong happened. And if you see here it said that resource not found string resource ID, like if you'll keep on fixing multiple fatal exceptions, you will realize what kind of error is this? Like when do you get this error? So basically you get this error when you try to set an integer to a text view. This is what we did in here. See I removed the concatenation with string and I'm trying to set an integer on the text view. So it says, oh no, I cannot find this string. So if you just do this and then run the app, like right now it was crashing, right? Now you enter 10 and 10 and say add. So everything will work fine. So whenever your app crashes or something wrong happened, I would suggest like how to go with that. Initially add logs everywhere. Like how do you add log? Android logging is like quite powerful. Add log at every step because that you can remove, right? And that you can see even in your log cat so that you know at which step you are okay with the process and at which step it failed. So you can just say L-O-G, which is Android util, then say D. This is like verbose or debug or you wanna mention that there was some error. So this is D is for debug, just an informative message you wanna print. You can name anything, like you can tag it with anything. This is the tag with which you can filter your logs. And then say got number one plus what is the number one value? Like if you print these logs, then got number two and then say okay, got result. Now for example, if something wrong would have happened in number two this thing, then your these logs will not get printed because something wrong happened with the application. So you know until here things were working because you saw this log. Like for example, right now we will run this application so that we can see the logs. And I'll say 10 and say 10 and I'll say add 20. Now I'm gonna filter with this log. Okay. And this is the filter thing. So see if you see W, W code, so I said got number one, okay, I could have given some space. Got number one, 10, got number two, 10, got result 20. If something wrong would have happened you would not have gotten all the logs. And that way it will be easier for you to figure out, okay, what exactly happened? Where exactly things went wrong? I think there's no way to say it was expecting a string, but we were setting integer. Yes, yes. So by concatenating, so this is the very easiest way to, okay, other thing would have been, oh it's small this thing. So it will not actually string, you will create string builder and then do this. So as I said the easiest way. And because it's a primitive type, it's not the wrapper type integer. So the easiest way to convert anything into string is like concatenate that with string. So do you understand about those views which we were looking for kind of a return type? Yeah, so, okay, result text view dot set text. Now you don't know what set text expects, right? So you go there, like click and you go into Android. So this is like Android documentation. This is the actual text view dot Java, like from the Android API. And if you see here, see it expects a care sequence. Care sequence is nothing but a string only or you can read about it, like what kind of parameters it expects. And sometimes these kind of errors are like really dangerous. Like if I don't do this, it like ID doesn't throw me an error, like what I'm trying to do. It will only throw you an error when you will try to run the app. So yeah, it happens, shit happens. Yeah, so I think everybody is able to see 10 plus 10 is 20, right? So yeah, that's it guys. That's it for today. And if you have any questions, do let me know or you'll know. She's already a good Android developer. She is a great contributor for Mickey. And please, yeah, do test it. Even I contributed a bit of Android in that, but do test it, split bill. And if you are learning Android, I would suggest that you also participate in. We have our own Slack group. Yeah, yeah, we have our own Mickey Slack group. So you guys can join that Slack channel and then you can, yeah, you can contribute to that project. That would be the easiest way to learn Android. So is your coding accessible? Okay, thank you guys.