‫-: Hi. Within this lecture, we are going to see how
‫we can create an APK, a final product out of this app
‫that we have developed in the previous lecture.
‫And now we are going to see how we can use that APK
‫in our emulator or in our Android devices.
‫So over here right now, if I run this app
‫it'll run on my emulator,
‫but most of the time
‫when you commit a reverse engineering
‫when you try to do
‫a reverse engineering for some kind of an app,
‫you won't get the source codes, okay?
‫You will only get apk,
‫and you will try to actually de-compile it
‫and get the source codes or dalvik bytecodes out of it.
‫So you have to know, how to create an APK
‫and how to work with APKs in general.
‫So if you come over here to your build menu,
‫you will see a menu like this, build bundles and APKs.
‫So also you will see a generate signed bundle APK
‫option as well.
‫We're going to see both of those
‫and we're going to work with both of those.
‫And the second one is to create a signed APK,
‫a signed apk means that you sign it as a developer,
‫it identifies you as a developer
‫of this Android application.
‫So for example, if you want to put your app
‫on the app store, I mean Google Play in Android, of course,
‫you have to sign it, so that Google Play
‫will know that you are the developer.
‫However, in this case,
‫when you try and when you do some tests,
‫it's perfectly okay to come over here
‫to build bundle or APK's and choose build APK's.
‫So this will create the apk in the same way.
‫You will get the latest product, a final product
‫of this development, but it won't be signed.
‫And in fact, we will see how to sign it manually
‫like we did in the backdoor section as well.
‫Just let me show you this as an example.
‫If I come over here to generate signed APK,
‫it'll ask me for,
‫if I want to create a bundle or APK, I'm gonna go for APK.
‫And once I do that, it'll ask me for a key store path.
‫So remember, a key store that we have created using terminal
‫in the backdoor section.
‫So this is the same thing.
‫It asks for a key store, and if you don't have
‫a pre-created key store, you can create a new one,
‫from here, from this menu.
‫And then you can use it to sign your APK
‫so that you can actually use it in any device
‫or in Google Play as well.
‫So if you come over here, if you hit, create new,
‫you will see that it will ask for a path
‫and it'll ask for your name and organization,
‫city and some stuff like that.
‫And of course, we've done this before.
‫We are gonna do it again, later on.
‫But again, for tests and other things,
‫you can actually use this Build APKs
‫and once you click on it, it'll just generate the APK.
‫Create the apk, and put that in a folder like this.
‫So it's very simple.
‫Now, if you click on Locate,
‫over here or if you open your,
‫your own project file,
‫like, this is inside of my project right now,
‫my reverse app, as you can see, my reverse app, and then app
‫you can actually find it from here and then build
‫and then outputs, and then APK, and then debug.
‫And then here you go, app debug APK.
‫So this is the apk generated for us.
‫And it's very simple as you can see.
‫You can just click on the menu
‫and it'll generate an apk for you.
‫Now we can use this apk to reverse engineer.
‫Now, if you have skipped the previous lectures
‫for some reason,
‫I'm going to explain how to use apk in an emulator
‫or in any android device, one more time.
‫So if you already watched this,
‫if you already can start APKs,
‫if you already can use APKs in your emulator,
‫you may as well as skip this lecture
‫and continue with the next one.
‫So right now, I'm going to stop my emulator.
‫Okay, here you go.
‫I'm actually going to stop every app
‫that I have on my emulator running right now,
‫so that we will have a clear system
‫and we will start from scratch.
‫Now, if I come over here to my emulator, I suppose
‫that I want to use my app debug apk in this emulator
‫and I don't know how it's done.
‫So first thing to do is to actually uninstall my reverse app
‫in this case, because we already have it installed.
‫So let me uninstall this first of all.
‫Okay, here we go.
‫We got rid of the my reverse app.
‫So next thing to do is to make sure that
‫we can actually install APKs from other sources
‫rather than Google play in this phone, in this emulator.
‫It doesn't matter if it's an emulator
‫or if it's a real Android device,
‫you can actually change the setting
‫whenever or wherever you want. Okay?
‫So this will enable us to download
‫and use APKs other than Google Play.
‫So if you come over here to settings, and you,
‫you can actually search for this setting
‫because there are so many versions of Android
‫and so many versions of other phones and devices.
‫So it's a little bit hard to find it through the menus
‫that if you search for install, okay, unknown,
‫you will actually see this install unknown apps.
‫So make sure you click on that
‫and find install unknown apps one more time, like this.
‫And allow Chrome or other applications over here
‫to download APKs and install it.
‫So in our case, I'm going to allow Chrome
‫so that I can actually download whatever I want
‫from a website or a cloud source that I put my APKs on.
‫Okay? So make sure you do that.
‫And in fact, in our case, it, it won't be even necessary
‫to download something from the internet.
‫We're just gonna drag and drop this APK
‫and it will work most of the time.
‫But it's essential that you know how to work with this stuff
‫because in a real device, in a real Android device
‫all you have to do is just download this APK
‫and make sure you installed it on your phone
‫or device or tablet so that it will run.
‫For example, in emulator, you can just drag and drop
‫like this, as I said before, and it will be installed.
‫Here you go. Now I can actually run this
‫and play with this, okay?
‫And it's not the case in a real Android device.
‫In that case, you have to upload this apk to a file
‫or a file upload your website
‫and then download it to your Android device and then run it.
‫So that's why we have learned about this
‫unknown sources in Chrome and everything.
‫So in order to upload your app
‫you can use any platform you want.
‫I generally use this files fm.
‫This is kind of weupload or transfer upload website, okay?
‫But it allows us to upload APKs as well.
‫So some of the platforms actually block this
‫and files fm do not, does not block APK.
‫So you can actually upload them whenever you want from here.
‫Okay? For example, I'm gonna do that.
‫I'm just going to say, start file upload.
‫And as you can see, it gives me a link.
‫Now, if I go to that link
‫from my device or from my emulator or from my phone,
‫I can actually download it and install it on my device.
‫So this is another alternative
‫rather than dragging and dropping the APK. Okay?
‫And the third alternative may be just
‫using the terminal or Android debug bridge
‫in order to use, in order to install APKs.
‫But make sure you remember this files fm
‫because we are going to use this a lot during this course,
‫as well as during your,
‫most probably in your real life as well.
‫So over here I have my emulator working
‫and I can actually reach that emulator by Android,
‫calling Android debug bridge, which is ADB.
‫And in order to do that, I'm gonna open terminal
‫in my Android studio and I will run some commands.
‫So this is the same thing basically
‫by opening your command prompt or terminal,
‫but you can actually do this inside of your Android studio.
‫So in Windows, you can call cls
‫in order to clear the screen.
‫And in Mac, of course, you can call clear
‫and then we are going to use adb. Okay?
‫But as you can see, I,
‫I have typed, adb install
‫and it says that command not found.
‫Actually, we have seen how to deal with this problem before
‫but in case you missed it,
‫I'm just going to show you one more time.
‫And in fact, I'm just going to show you another
‫solution this time.
‫So this generally becomes a problem
‫in MAC operating systems. Okay?
‫So I'm gonna search for this.
‫I'm gonna search for, adb command not found.
‫So I'm getting an error
‫and I just want to know how to solve it.
‫So I'm searching it in Google, okay?
‫And let me go to Google and say, adb not found,
‫maybe adb command not found.
‫And most probably I will see a lot of results like this.
‫Okay? Millions of results.
‫Then I'm gonna go into stackoverflow.com,
‫which is my favorite website
‫as well as, its favorite websites for every developer
‫in the world as well.
‫As you can see, there are a lot of solutions
‫for, adb command not found problem.
‫So if you are on Mac, and if you're getting this error
‫you can use the previous solution
‫that I have offered you in this course,
‫or you can try to export the paths like this, okay?
‫And it will add the paths to your platform
‫and you can use adb without having a problem.
‫And I suggest you use this code, echo export path, okay?
‫You can actually find this code from this website
‫or I can share this on my resources as well.
‫But once you do that, it'll add this path
‫to your profile so that you can use it whenever you want.
‫And in order to make this work,
‫I'm going to paste this over here
‫and it'll be run for me.
‫Now if I run adb install, let's see.
‫Yeah, it says that, command not found,
‫but over here it says that
‫you have to restart android studio.
‫So let's do that.
‫Let's close down and open one more time
‫and let's see if this works this time.
‫And I'm doing all of this, in order to make sure,
‫you know how to use APKs in emulators or in devices.
‫As you can see now, adb works.
‫Now if I say, adb install, it will ask for a requirement,
‫it will ask for a parameter.
‫It's asking for the apk itself.
‫So I'm gonna go over to my desktop
‫which I can go by saying, cd desktop.
‫However, apparently, I'm not inside of my home folder,
‫so I'm gonna say cd.. cd..,
‫then I can go to cd desktop, and here you go.
‫Now we can see pp debug apk.
‫Now I'm gonna run adb install app debug apk.
‫And now, yeah, it says that it's already over there
‫so you don't need to do this one more time.
‫But as you can see, we found the third way
‫of installing an apk into an emulator.
‫So you know how to work with this,
‫with three various ways right now.
‫So if one of them fails, just make sure you try another one
‫and make sure you follow the stackoverflow or googling
‫in order to solve your problems in real life as well,
‫like we did in this lecture.
‫So now we have our apk
‫and we know how to work with APKs in emulators.
‫Now it's really the time to decompile this
‫and manipulate it in a way that we want.
‫Let's do that in the next lecture.