 Hello, months ago, months ago, at the beginning of this year, I promised you guys that I would show you how to package an Android application completely from the shell without the Android Studio. Because most of the tutorials you watch out there, you find they want you to use the Android Studio, which is, one, unnecessary. I think it's a lot of bloat. And just to get that set up, just to make a Hello World app for your Android device, it's going to be somewhere between four and eight gigs worth of downloads. We are going to minimize that today. We're going to do everything in the shell. I have an example code up on GitLab that we're going to be working with, along with all the instructions I'm going to show you today. I'll link to that in the description of this video. But basically, we're going to pull down the minimum amount of stuff to link the stuff we don't need. And we're going to get it under a half a gig, which is still huge. It's going to be 400 some megabytes, but it's still better than four gigs worth of stuff. And then we're going to package up and put the APK, the app, on a device. So I'm not going to go too much into creating the app. Right now, we're just going to be packaging it. I'll show you how to make a few modifications to it. But let's go ahead and get started and look at this. Okay, right here, we are at my GitLab page for this project. It's Android Hello World APK. Again, there'll be a link in the description of this video. And we are going to just follow these instructions I have in the readme. Okay, so I'm going to go to the shell and in my home directory, I already have an Android directory. I'm going to remove that. So we're starting from scratch, but we're going to put everything in this directory. So first, we're going to download the command line tools. So I have the link here, we're just going to W get that. And we're going to pull it down to our temp directory here is labeled as the latest, but always check their website to make sure you get the latest. Then I'm going to make the directory I just deleted and the Android directory, and we're going to move into it. And then we're going to unzip that zip file we just downloaded. So again, we're just copying pasting stuff from my readme file. Next, from there, we're going to move into the command line tools directory, we're going to make a directory called tools. And then we're going to move everything from there into our tools directory, just to kind of organize stuff. And you'll get an error that you can't move tools into itself, which is fine. That makes sense. Now, to get this all to work, we have to add some things to our path directory. The path is a variable that tells your system where executables are, right? So we're going to tell it to look inside this Android directory. And there's some subdirectories with that's going to have our tools in there. One of these I have listed here is the emulator. I'm going to leave that in here in case you want to use the emulator. But one of the things we're going to do is delete the emulator because it's over a gig worth the stuff. And I'm just going to push things to an actual device. So I never use the emulator. So we're going to put this in our shell for now. But for this to be persistent, you're going to have to put it in your shell's RC file. So if you're using bash, in your home directory, you should have a dot bash RC file. Or if you're using Z shell, it'll be in your home directory dot zshrc, or whatever shell you should probably know how to do this. You put that in there. And that means anytime you load your shell, it's going to load these variables. So we're going to go ahead and just put them in here for now. But be aware you have to add that to your RC file. Okay, now we've downloaded the command line tools. And we've told to where to look for tools, some of which we haven't downloaded it, but we need to download the SDK, the SDK are necessary tools for packaging up applications, you can do SDK manager. So now this will be in the tools we just downloaded. And that's why we can just type it in there because we've added to our path. If you don't add to the path, you try to run this, you're going to get an error. You can do that and it will list out all the different SDKs because every version of Android has different SDKs. And obviously, and when I did that, there's newer ones, it looks like they're up to 34. When I originally wrote this, I think 29 must have been the newest. But we're just going to go ahead and use that SDK manager to install the platform tools for Android 29. Okay, and the build tools. We're going to use the yes command. What's the yes command do? The yes command just prints out yes, yes, yes, or why, why, why, why. Basically, when you run this, it's going to ask you to agree to some licenses. And instead of having to click yes for all them, we're just going to tell it to automatically say yes to everything. So we're going to do that. And again, I'm going to install the build tools for Android 29. Look and see whatever the newest one is that works for you. We'll just take a moment because this is going to be like a gig and a half worth of stuff. In fact, we'll check the size of stuff once that's downloaded. But once that's downloaded, what I'm going to do next is I'm going to remove the emulator folder. And I'm going to remove the tools folder because we already downloaded the command line tools. We'll remove those two things. And then we're ready to go. We can package up our application. And that was weird. So 90%. It's unzipping some stuff. Now we did that. I'm going to move out of this directory for a sec. And I'm just going to do du dash h to see how big everything is now. So we have 1.4 gigs, which is still a lot smaller than if you installed the Android studio. But again, we can do better. I am going to remove emulator. And if we run our DU tool again, now we went from 1.3 gigs down to 574 megabytes. If you need the emulator and keep it installed, I have plenty of Android devices. I always just push everything and test it on actual hardware. Next again, we can remove the tools directory because we already have a tools directory again from the command line tools we installed. And that takes off like another 100 megabytes over 100 megabytes. So now we're down to just over 400 megabytes, which again, in my opinion, is super huge just for building a Hello World application. And maybe it could be stripped down even more. But that's where we're at now. But again, we're ready to build. So let's go ahead and continue looking at my notes. Now, let's pull down my project here. You can pull it down. I'll click this zip file. And I will put it in my temp directory. I will move into my temp directory. And I will unzip that zip file. And then I will move into that project. Okay, so this is my project from GitLab. We can start compile other things like you may want to change the icon. So if you just change this file, it will change the icon. And when you have icons for Android applications, you can have multiple sizes and formats for different scenarios. But for this, if I was just to open it up with GIMP, you can see the icon for this app looks like this. That's just the default icon I put there. Change that and that will change what the icon looks on when you install it on the device. But once you change that, you can go ahead and do build. So dot slash gradle build. Because in here, there's the gradle script right here, right? So we're going to run that. It's gradle w build. And then I also add the ampersand ampersand. This is saying if successful, then install it to the device. You can install the debug version or there is a release version under release apk. And that's if it is successfully compiled. So what you should at this point, it's saying that the apk failed to install. Let me do the debug version because that's what I normally do. Let's try that again. There we go. So install the debug version. Again, this is a minimal tutorial and we're going to install the debug package. If you actually want to deploy this on like Google Play or the Google Play Store, you're going to have to create a release and you actually have to create these days an abb file, I think is what it's called, and you have to sign it. This is just minimal get you going, push it to your device. Now, if I go over to the device that I just installed it to, let's get the screen on here, you can see I have the hello world right here with that icon. We said it says hello world. We click on that. And again, the app's called hello world. And it says hello world. So again, we can change the icon if we wanted. But there's real quick, I'm going to change some other things. So what I'm going to do is I'm going to go into our app here. And if we look at strings, this is a place where you can put variables. So like the app name, I can change the app name here and I can call it my app. If I was to repackage it, rebuild it. And again, I will do the debug APK. That will push it over to the device, reinstall it. And now it says my app. And when I click on it, you'll say my app at the top here. Another thing we can change, if we were to edit the manifest file, oops, where's the manifest file? Source main Android manifest file. Here you can change the package name. So by default, this says com.filmsbychris.hello. So you can change that to something else. Obviously, you would put in whatever name you want to name it. It's kind of a standard to have it be your website backwards and then the name of the package at the end here. I think that's a little weird, but it's kind of a standard. You don't have to do that. Now, another thing we can change, if we were to go into here, instead of strings, strings is where you can keep variables for it. But what we can also do is go into resources, layouts, main activity here. And you can see that I have a text view. That's what this is. It's a text view. And down here, I'm saying string hello world. That's a variable from the other file. But I can just edit this. So delete in that. And I can say this is a test. And I can package and push that. If everything builds correctly, we will have it reinstalled here. And when I click on this, now it says this is a test. So that's a little bit on chain modifying the application. Again, this tutorial isn't too much on creating the app, but just packaging it. So you pull down my example, and now you have a basic hello world. So that's it. Again, I feel like it's super simple. You just basically copy and paste. Oh, I forgot something. Let's go back to my GitLab here. If you get an error when you're trying to build it, something that may be the issue is your version of Android. So what you can do is you can run at least a Debian based system. So Ubuntu, MX Linux, that sort of thing. We're going to do sudo update alternative dash dash config Java. When you wrote write that versions of Java you have installed. And I recommend for me version 11 works. So I already have that selected, but you put in the number of the one you want. So in this case one, but whatever Java 11 is, that's if you get an error filing. And then at that point, you can export some more paths telling it to where to look for that Java. So if you get compilation errors, try running that. That's it. Hope you enjoy this tutorial. Again, it's just copying and pasting stuff from my GitLab page. Hopefully it works for you. It's worked for me on my Debian based systems. I've tried it on MX Linux and other Debian based systems. If you have any problems, I don't know if I can help you. It took me a long time to get this far. I really hate Android development. But it's something I feel like I should know. So I've been learning more about it. But I didn't want to install four or five gigs worth of stuff just to create a hello world. So I have this example. I'll show you other examples in the near future where I run system commands, thread stuff to loop stuff in the background. And a few other things. Oh, and the big one is packaging websites, whether it's a local HTML that's in the package or actually pointing to a website. And basically it's turning into an application that loads a website. And then you can just develop your app in HTML and package it this way. And I've tried to simplify that process. We'll talk about that in future videos as well. Filmsbychris.com. That's Chris of the K. There's a link in the description. Again, I'll put in a link to this package there. But you can also go to gitlab.com for slash metal x 1000 and just search for Android Hello World APK and you should be able to find it. Thanks for watching. As always, I hope that you have a great day. I do have a Patreon page. Check that out below. And again, have a great day.