1 00:00:00,180 --> 00:00:04,260 ‫-: Hi, within this lecture we are going to integrate Firebase 2 00:00:04,260 --> 00:00:06,150 ‫with our own project. 3 00:00:06,150 --> 00:00:07,320 ‫And in order to do that 4 00:00:07,320 --> 00:00:11,100 ‫of course we are going to create the project first of all. 5 00:00:11,100 --> 00:00:14,675 ‫So I'm going to open my androidstudio, okay? 6 00:00:14,675 --> 00:00:17,790 ‫And I'm going to create an empty project 7 00:00:17,790 --> 00:00:21,180 ‫and we are going to do everything from scratch together. 8 00:00:21,180 --> 00:00:24,000 ‫So make sure you open your androidstudio 9 00:00:24,000 --> 00:00:28,620 ‫and make sure you open a new androidstudio project. 10 00:00:28,620 --> 00:00:33,600 ‫So of course you could have used my codes in GitHub as well 11 00:00:33,600 --> 00:00:36,840 ‫but it's important that you understand the structure 12 00:00:36,840 --> 00:00:41,070 ‫of this app so that we will do it together 13 00:00:41,070 --> 00:00:43,170 ‫and you will have an understanding 14 00:00:43,170 --> 00:00:48,170 ‫of how apps like this are built from scratch, okay? 15 00:00:49,470 --> 00:00:52,440 ‫And even if you're not an android developer 16 00:00:52,440 --> 00:00:55,680 ‫if you're looking to be a mobile ethical hacker 17 00:00:55,680 --> 00:00:59,406 ‫I suggest you learn these things and I suggest you 18 00:00:59,406 --> 00:01:03,960 ‫just improve your android development skills. 19 00:01:03,960 --> 00:01:08,100 ‫So I'm going to come over here after choosing empty activity 20 00:01:08,100 --> 00:01:11,910 ‫and name my application SecureTweetApp. 21 00:01:11,910 --> 00:01:13,980 ‫It doesn't have to be necessarily 22 00:01:13,980 --> 00:01:18,980 ‫as the same as we have chosen in Firebase app, okay? 23 00:01:19,500 --> 00:01:21,690 ‫So I'm going to use this 24 00:01:21,690 --> 00:01:25,200 ‫and I'm going to use this package name. 25 00:01:25,200 --> 00:01:29,730 ‫So this is what we are going to give Firebase, okay? 26 00:01:29,730 --> 00:01:33,930 ‫So make sure this is not followed by com.example 27 00:01:33,930 --> 00:01:35,670 ‫but com. your name. 28 00:01:35,670 --> 00:01:39,420 ‫I'm going to choose minimum API level of 23. 29 00:01:39,420 --> 00:01:42,450 ‫As I said before, it doesn't really matter at this point. 30 00:01:42,450 --> 00:01:45,930 ‫You can go for the latest version, but I'm gonna go 31 00:01:45,930 --> 00:01:48,960 ‫for 23 because it's kind of a habit 32 00:01:48,960 --> 00:01:53,960 ‫for me and I'm going to choose Java as the language. 33 00:01:54,180 --> 00:01:58,650 ‫Then I'm going to say finish and my project will be created. 34 00:01:58,650 --> 00:01:59,980 ‫Great. 35 00:01:59,980 --> 00:02:04,980 ‫Next thing that we are going to do is to integrate Firebase 36 00:02:05,220 --> 00:02:07,470 ‫into our project. 37 00:02:07,470 --> 00:02:10,080 ‫And then after we do that we are going to copy 38 00:02:10,080 --> 00:02:13,620 ‫and paste everything from my GitHub account so 39 00:02:13,620 --> 00:02:17,220 ‫that we will have a working Firebase app 40 00:02:17,220 --> 00:02:19,620 ‫like a Twitter app, okay? 41 00:02:19,620 --> 00:02:21,180 ‫So here you go. 42 00:02:21,180 --> 00:02:24,960 ‫I believe it's ready for us right now. 43 00:02:24,960 --> 00:02:29,115 ‫Let me try to open, yep, it's already opened for me 44 00:02:29,115 --> 00:02:32,820 ‫and I can see my package name from here. 45 00:02:32,820 --> 00:02:35,310 ‫Okay, this is what we need in order 46 00:02:35,310 --> 00:02:39,660 ‫to give to the Firebase over here. 47 00:02:39,660 --> 00:02:41,820 ‫So I'm going to copy and paste this. 48 00:02:41,820 --> 00:02:45,000 ‫And for nickname, this is optional, but you can just 49 00:02:45,000 --> 00:02:48,720 ‫write the same thing like project name over here. 50 00:02:48,720 --> 00:02:53,430 ‫I'm gonna call this SecureTweetApp, and then later 51 00:02:53,430 --> 00:02:55,460 ‫on I'm gonna register my app. 52 00:02:55,460 --> 00:02:58,920 ‫So make sure you copy your own package name 53 00:02:58,920 --> 00:03:03,210 ‫rather than mine because I believe it has to be unique. 54 00:03:03,210 --> 00:03:06,660 ‫And if you chose mine, then it'll give you an error. 55 00:03:06,660 --> 00:03:11,660 ‫Next thing, it asks you to download a configuration file. 56 00:03:12,150 --> 00:03:13,650 ‫This is very important. 57 00:03:13,650 --> 00:03:16,348 ‫If you don't do the step, then your 58 00:03:16,348 --> 00:03:19,380 ‫androidstudio project will not be connected 59 00:03:19,380 --> 00:03:21,780 ‫to your Firebase project. 60 00:03:21,780 --> 00:03:26,780 ‫So this is the file that lets us connect our project 61 00:03:26,820 --> 00:03:31,740 ‫to the Firebase server and it has the configuration file 62 00:03:31,740 --> 00:03:34,230 ‫like it has the usernames 63 00:03:34,230 --> 00:03:37,860 ‫and keys and passwords and hashes and stuff. 64 00:03:37,860 --> 00:03:39,870 ‫In order to make it work 65 00:03:39,870 --> 00:03:43,890 ‫you have to click on this, download Google Services JSON 66 00:03:43,890 --> 00:03:46,980 ‫and it'll download the file for you. 67 00:03:46,980 --> 00:03:50,190 ‫And after it's completed, you're gonna have to 68 00:03:50,190 --> 00:03:53,940 ‫change the view of your project like this. 69 00:03:53,940 --> 00:03:57,330 ‫So this is android view by default 70 00:03:57,330 --> 00:03:59,160 ‫and then you're gonna have to switch it 71 00:03:59,160 --> 00:04:02,190 ‫to project view so that you can see all the files 72 00:04:02,190 --> 00:04:06,300 ‫and folders and make it into the right place like this. 73 00:04:06,300 --> 00:04:10,800 ‫So go to project view and open your app. 74 00:04:10,800 --> 00:04:13,710 ‫Not this one, open your app folder. 75 00:04:13,710 --> 00:04:16,710 ‫So this is where you should put it into 76 00:04:16,710 --> 00:04:19,620 ‫and of course you can see the right place 77 00:04:19,620 --> 00:04:22,380 ‫from the documentation as well. 78 00:04:22,380 --> 00:04:27,380 ‫So I'm gonna find my Google services JSON file 79 00:04:28,140 --> 00:04:30,570 ‫and I believe it's not over here even 80 00:04:30,570 --> 00:04:32,550 ‫though I have downloaded it. 81 00:04:32,550 --> 00:04:35,490 ‫So let me come back to my Safari 82 00:04:35,490 --> 00:04:37,890 ‫and let's see if we managed to download it. 83 00:04:37,890 --> 00:04:40,560 ‫Yep, it's timed out for some reason. 84 00:04:40,560 --> 00:04:43,410 ‫Let me try one more time and here you go. 85 00:04:43,410 --> 00:04:45,450 ‫Now I believe it's over there. 86 00:04:45,450 --> 00:04:47,400 ‫So let me open it. 87 00:04:47,400 --> 00:04:48,300 ‫And here you go. 88 00:04:48,300 --> 00:04:50,280 ‫googleservices.JSON. 89 00:04:50,280 --> 00:04:53,160 ‫It has to be exactly the same name. 90 00:04:53,160 --> 00:04:56,370 ‫Don't change this name, googleservices.JSON. 91 00:04:56,370 --> 00:04:58,380 ‫And it's in the app folder. 92 00:04:58,380 --> 00:05:02,070 ‫Just say okay, so if it's named something else 93 00:05:02,070 --> 00:05:07,070 ‫for example googleservices.JSON2, then it won't work. 94 00:05:07,290 --> 00:05:10,230 ‫Make sure it has the same name 95 00:05:10,230 --> 00:05:14,313 ‫it has the original name like this Google Services JSON. 96 00:05:15,270 --> 00:05:20,270 ‫So over here you can just say reveal in Finder 97 00:05:21,060 --> 00:05:26,060 ‫or reveal in Windows folders so that you can just drag 98 00:05:26,160 --> 00:05:30,723 ‫and drop your Google Services file over here as well. 99 00:05:30,723 --> 00:05:33,180 ‫This is an alternative 100 00:05:33,180 --> 00:05:37,020 ‫if dragging and dropping doesn't work for you 101 00:05:37,020 --> 00:05:41,190 ‫but most of the time dragging and dropping will work. 102 00:05:41,190 --> 00:05:43,172 ‫So you won't need it, but if you need it 103 00:05:43,172 --> 00:05:45,960 ‫you can open your SecureTweetApp 104 00:05:45,960 --> 00:05:50,490 ‫from your files and folders and bring it in. 105 00:05:50,490 --> 00:05:52,920 ‫So this is what we needed to do. 106 00:05:52,920 --> 00:05:56,880 ‫So I'm gonna switch back to android view, and this is done. 107 00:05:56,880 --> 00:06:01,880 ‫So I'm gonna say next it will ask me to add the SD case. 108 00:06:02,460 --> 00:06:05,430 ‫So these are software development kits 109 00:06:05,430 --> 00:06:07,200 ‫that I was talking about. 110 00:06:07,200 --> 00:06:10,170 ‫So this is what is great about Firebase. 111 00:06:10,170 --> 00:06:11,610 ‫It lets us communicate 112 00:06:11,610 --> 00:06:16,110 ‫with our Firebase server through our code. 113 00:06:16,110 --> 00:06:19,590 ‫We will write Firebase code inside 114 00:06:19,590 --> 00:06:23,850 ‫of our androidstudio thanks to this Firebase SD case. 115 00:06:23,850 --> 00:06:26,550 ‫And in order to download them to our project 116 00:06:26,550 --> 00:06:28,950 ‫we are going to use build.gradle. 117 00:06:28,950 --> 00:06:32,340 ‫Remember we use build.gradle to specify 118 00:06:32,340 --> 00:06:34,080 ‫the dependencies and libraries 119 00:06:34,080 --> 00:06:37,980 ‫that we are going to use inside of our project. 120 00:06:37,980 --> 00:06:40,200 ‫So this is one of them. 121 00:06:40,200 --> 00:06:43,140 ‫And there are two build.gradles, one 122 00:06:43,140 --> 00:06:47,190 ‫of which is project level, and the other one is app level. 123 00:06:47,190 --> 00:06:50,820 ‫We generally use app level build.gradle, but 124 00:06:50,820 --> 00:06:55,350 ‫in this case it asks us to use project level 125 00:06:55,350 --> 00:06:58,590 ‫and build that app level together. 126 00:06:58,590 --> 00:07:00,450 ‫So make sure you find both 127 00:07:00,450 --> 00:07:04,050 ‫of these files and make sure you edit them. 128 00:07:04,050 --> 00:07:06,990 ‫So first we are going to start with project level. 129 00:07:06,990 --> 00:07:09,390 ‫So I'm going to show you where it is located. 130 00:07:09,390 --> 00:07:11,310 ‫It's under gradle scripts 131 00:07:11,310 --> 00:07:14,040 ‫and the first one is project like this. 132 00:07:14,040 --> 00:07:15,960 ‫Just double click on this, okay? 133 00:07:15,960 --> 00:07:17,340 ‫And open it. 134 00:07:17,340 --> 00:07:20,850 ‫And there are some things that we need to check for. 135 00:07:20,850 --> 00:07:23,730 ‫For example, first of all, it says that check 136 00:07:23,730 --> 00:07:26,490 ‫that you have Google in your repositories. 137 00:07:26,490 --> 00:07:29,700 ‫And as you can see I have Google over here. 138 00:07:29,700 --> 00:07:32,520 ‫So if you don't have it, just write Google 139 00:07:32,520 --> 00:07:35,400 ‫with parenthesis and under dependencies 140 00:07:35,400 --> 00:07:38,790 ‫you have to copy this line from here class path 141 00:07:38,790 --> 00:07:43,790 ‫and paste it under your regular class path like this, okay? 142 00:07:44,250 --> 00:07:47,010 ‫And after that, again we have 143 00:07:47,010 --> 00:07:49,290 ‫another repository section where 144 00:07:49,290 --> 00:07:53,640 ‫we should add Google, and it's already over there for me. 145 00:07:53,640 --> 00:07:56,430 ‫So this is for the project level 146 00:07:56,430 --> 00:07:58,860 ‫build.gradle, and we are done. 147 00:07:58,860 --> 00:08:02,220 ‫Now we are back to the app level. 148 00:08:02,220 --> 00:08:03,973 ‫So let's go to the app level. 149 00:08:03,973 --> 00:08:08,973 ‫And here we have apply plugin like this over here. 150 00:08:09,510 --> 00:08:13,350 ‫Okay, so as you can see I already have it. 151 00:08:13,350 --> 00:08:18,350 ‫So under dependencies we should add for new SD case 152 00:08:18,780 --> 00:08:21,652 ‫and we are going to see how to do that, okay 153 00:08:21,652 --> 00:08:23,910 ‫with the following lecture. 154 00:08:23,910 --> 00:08:27,990 ‫But at the end of the line, at the end of the bottom 155 00:08:27,990 --> 00:08:32,430 ‫of this file, we are going to copy and paste this as well. 156 00:08:32,430 --> 00:08:34,380 ‫So this is what we need to do 157 00:08:34,380 --> 00:08:36,840 ‫in order to be ready for Firebase 158 00:08:36,840 --> 00:08:39,570 ‫But of course we are going to have to bring 159 00:08:39,570 --> 00:08:41,640 ‫in some additional dependencies 160 00:08:41,640 --> 00:08:45,210 ‫for this as suggested in the documentation. 161 00:08:45,210 --> 00:08:49,143 ‫So we are going to see how it's done in the next lecture.