1
00:00:00,397 --> 00:00:03,080
(light music)

2
00:00:03,080 --> 00:00:05,220
(computer keys clicking)

3
00:00:05,220 --> 00:00:07,580
Before we continue with the TaskTimer App,

4
00:00:07,580 --> 00:00:09,780
let's review what happens when various parts

5
00:00:09,780 --> 00:00:14,280
of Android Studio as well as the Android SDK get updated.

6
00:00:14,280 --> 00:00:16,353
So I've started up Android Studio

7
00:00:16,353 --> 00:00:17,516
and you can see that we have got

8
00:00:17,516 --> 00:00:18,860
some updates waiting for us.

9
00:00:18,860 --> 00:00:20,600
But I also wanna show you the process

10
00:00:20,600 --> 00:00:23,100
of updating the Android SDK.

11
00:00:23,100 --> 00:00:26,823
So we're going to Configure, and we'll select SDK Manager.

12
00:00:28,793 --> 00:00:29,960
And when I do that you can see at the moment now

13
00:00:29,960 --> 00:00:33,090
we've got a new version, Android 9.0 Pie.

14
00:00:33,090 --> 00:00:34,900
So that's our new release.

15
00:00:34,900 --> 00:00:38,170
And new release comes through once or twice a year.

16
00:00:38,170 --> 00:00:40,960
We had Android 8 last year and then an 8.1 update.

17
00:00:40,960 --> 00:00:43,614
So what we're gonna do is update to Android 9.

18
00:00:43,614 --> 00:00:46,150
So I'm gonna click on that button, the Android 9.

19
00:00:46,150 --> 00:00:48,350
And we're gonna click on Show Package Details.

20
00:00:48,350 --> 00:00:52,630
It tells us what parts of the Android 9 update we can take.

21
00:00:52,630 --> 00:00:56,750
I'm gonna click on Android SDK Platform 28 and Sources.

22
00:00:56,750 --> 00:00:57,610
And the other thing you should do

23
00:00:57,610 --> 00:01:01,390
is to select a system image that you'll actually be using.

24
00:01:01,390 --> 00:01:05,690
So or you can choose either say the Google API System image,

25
00:01:05,690 --> 00:01:08,300
or Google Play one, we've talked about the differences

26
00:01:08,300 --> 00:01:09,300
between those two.

27
00:01:09,300 --> 00:01:11,792
I'm also gonna grab the Intel x86.

28
00:01:11,792 --> 00:01:13,270
But you can grab whichever ones you need.

29
00:01:13,270 --> 00:01:14,930
So that's number one.

30
00:01:14,930 --> 00:01:18,260
Secondly, in SDK Tools, same thing,

31
00:01:18,260 --> 00:01:19,643
Show Package Details.

32
00:01:21,970 --> 00:01:24,730
We've quite older versions that were previously installed.

33
00:01:24,730 --> 00:01:26,410
I'm gonna grab the latest version as well,

34
00:01:26,410 --> 00:01:29,660
which in this case is 28.0.3.

35
00:01:29,660 --> 00:01:31,900
And we're gonna click on OK now that I've done that.

36
00:01:31,900 --> 00:01:34,020
It gives us an update on what it's about to do.

37
00:01:34,020 --> 00:01:35,120
I'm gonna click on OK.

38
00:01:37,070 --> 00:01:38,610
All right, so that's now gonna download

39
00:01:38,610 --> 00:01:39,610
and instal those things.

40
00:01:39,610 --> 00:01:42,414
So I will just fast forward this video

41
00:01:42,414 --> 00:01:43,247
so you don't have to wait too long

42
00:01:43,247 --> 00:01:45,040
while it downloads and instals everything,

43
00:01:45,040 --> 00:01:47,093
and we'll come back once that's complete.

44
00:01:54,040 --> 00:01:56,820
All right, so you can see that we've now completed that

45
00:01:56,820 --> 00:01:58,270
so I'm gonna click on Finish.

46
00:01:59,380 --> 00:02:00,830
And that part has been updated.

47
00:02:00,830 --> 00:02:03,733
We can go back into Configure, SDK Manager again.

48
00:02:03,733 --> 00:02:08,560
We can see that Android 9 is now showing as being updated.

49
00:02:08,560 --> 00:02:09,970
We've still got the older version.

50
00:02:09,970 --> 00:02:12,110
I'm gonna leave that there for now,

51
00:02:12,110 --> 00:02:14,083
and SDK Tools.

52
00:02:15,400 --> 00:02:16,740
We're doing a later version.

53
00:02:16,740 --> 00:02:18,780
So that's a good thing to have a recap

54
00:02:18,780 --> 00:02:19,920
on every now and again.

55
00:02:19,920 --> 00:02:22,940
But the next thing we'll do now is go into Task Timer

56
00:02:22,940 --> 00:02:24,150
now that we've updated.

57
00:02:30,440 --> 00:02:32,750
So things get updated on a regular basis,

58
00:02:32,750 --> 00:02:34,430
and I know we've covered some of this stuff before,

59
00:02:34,430 --> 00:02:36,950
but recapping it, I think, is a good idea

60
00:02:36,950 --> 00:02:39,053
because it's something that you'll need

61
00:02:39,053 --> 00:02:39,950
to do fairly often as Google update

62
00:02:39,950 --> 00:02:43,180
to support libraries and the Gradle build system.

63
00:02:43,180 --> 00:02:45,310
And there's also updates to the Kotlin language

64
00:02:45,310 --> 00:02:47,860
and the Kotlin plugin that Android Studio uses.

65
00:02:47,860 --> 00:02:49,180
So again, just a good recap

66
00:02:49,180 --> 00:02:52,190
of the various steps that are needed.

67
00:02:52,190 --> 00:02:54,560
So you can see that what's happened at the moment

68
00:02:54,560 --> 00:02:56,960
is that we've been told to take advantage

69
00:02:56,960 --> 00:02:59,517
of the latest version of Gradle and upgrade to 4.6.

70
00:02:59,517 --> 00:03:01,360
That number might be different

71
00:03:01,360 --> 00:03:03,990
depending on when you're watching this video.

72
00:03:03,990 --> 00:03:05,940
For now I'm gonna click on Remind me tomorrow

73
00:03:05,940 --> 00:03:07,870
just to show you an alternate way.

74
00:03:07,870 --> 00:03:10,160
I wanna actually show you what it's actually gonna change.

75
00:03:10,160 --> 00:03:12,373
Normally you would actually click Update there.

76
00:03:12,373 --> 00:03:14,170
So I'm gonna click on Remind me tomorrow.

77
00:03:14,170 --> 00:03:16,343
And we should find a Gradle file to build.

78
00:03:17,811 --> 00:03:18,919
And you can see, in fact,

79
00:03:18,919 --> 00:03:19,752
we've got an error at the top here,

80
00:03:19,752 --> 00:03:20,760
Kotlin not configured.

81
00:03:20,760 --> 00:03:23,280
So it did actually complete a build,

82
00:03:23,280 --> 00:03:24,580
but obviously with Kotlin not configured

83
00:03:24,580 --> 00:03:26,760
we've got various errors showing through here,

84
00:03:26,760 --> 00:03:28,640
which we need to fix.

85
00:03:28,640 --> 00:03:30,910
All right, so how would we do this manually?

86
00:03:30,910 --> 00:03:33,090
Well first we got that message about Gradle.

87
00:03:33,090 --> 00:03:35,540
We can actually come over here to Gradle Scripts.

88
00:03:36,680 --> 00:03:40,410
And there's this gradle-wrapper.properties.

89
00:03:40,410 --> 00:03:42,190
Double click that to open it.

90
00:03:42,190 --> 00:03:44,187
Sometimes that gets updated automatically.

91
00:03:44,187 --> 00:03:47,170
If you do get that earlier dialogue you can choose update,

92
00:03:47,170 --> 00:03:49,480
but here what I'm gonna do is manually change it.

93
00:03:49,480 --> 00:03:51,320
I'm gonna update it to 4.6 just

94
00:03:51,320 --> 00:03:53,600
to show you an alternate way of doing it.

95
00:03:53,600 --> 00:03:55,530
I'm gonna sync now.

96
00:03:55,530 --> 00:03:56,480
And that's going to actually

97
00:03:56,480 --> 00:04:00,380
download the new version of Gradle, that new version.

98
00:04:00,380 --> 00:04:02,165
You can see down at the bottom

99
00:04:02,165 --> 00:04:02,998
it's busily downloading things.

100
00:04:02,998 --> 00:04:05,190
For the first time when you select a new version of Gradle

101
00:04:05,190 --> 00:04:06,780
it goes through that process.

102
00:04:06,780 --> 00:04:09,150
And just another reminder here is that you can

103
00:04:09,150 --> 00:04:11,180
create a new project and check out

104
00:04:11,180 --> 00:04:12,650
all the equivalent files in there,

105
00:04:12,650 --> 00:04:15,947
comparing it to what you've currently opened.

106
00:04:15,947 --> 00:04:19,360
And this is basically a good process to go through

107
00:04:19,360 --> 00:04:20,899
if you've got an app that you haven't updated

108
00:04:20,899 --> 00:04:22,860
for a long time, you haven't opened in Android Studio

109
00:04:22,860 --> 00:04:24,600
for a long time when you want to update it

110
00:04:24,600 --> 00:04:27,840
to the latest version of the various support libraries

111
00:04:27,840 --> 00:04:30,170
and the Android SDK itself.

112
00:04:30,170 --> 00:04:31,520
So we'll just fast forward through this

113
00:04:31,520 --> 00:04:32,820
and wait for it to finish.

114
00:04:38,750 --> 00:04:41,030
All right so you can see that's now finished,

115
00:04:41,030 --> 00:04:42,420
and we've now got a successful build there,

116
00:04:42,420 --> 00:04:44,960
but if you go back to our source code

117
00:04:44,960 --> 00:04:47,270
we can also see now that's looking a bit healthier.

118
00:04:47,270 --> 00:04:48,890
We haven't got any errors anymore.

119
00:04:48,890 --> 00:04:50,550
So so far so good.

120
00:04:50,550 --> 00:04:52,940
The next thing to look at is to go back now

121
00:04:52,940 --> 00:04:55,363
into our regular projects build Gradle file.

122
00:04:56,891 --> 00:04:58,100
So build.gradle for our project.

123
00:04:58,100 --> 00:04:59,550
Open that up and have a look.

124
00:05:00,930 --> 00:05:04,660
And you can see at the moment we're using 1.2.51,

125
00:05:04,660 --> 00:05:05,680
the version of Kotlin.

126
00:05:05,680 --> 00:05:09,190
But also notice here the gradle plugin wants to be updated.

127
00:05:09,190 --> 00:05:12,700
Now that we've actually run the, or updated to 4.6,

128
00:05:12,700 --> 00:05:14,640
it's telling us there's an upgrade available.

129
00:05:14,640 --> 00:05:16,250
So I'm actually gonna change it

130
00:05:16,250 --> 00:05:18,560
to what it's asking for there, which is 3.2.1.

131
00:05:18,560 --> 00:05:21,051
And I can do that by just editing that file,

132
00:05:21,051 --> 00:05:22,431
3.2.1.

133
00:05:22,431 --> 00:05:24,670
But the other thing is the version of Kotlin is updated,

134
00:05:24,670 --> 00:05:26,630
and there's no indication here that it has.

135
00:05:26,630 --> 00:05:29,645
One way of finding that out is going into the Tools menu,

136
00:05:29,645 --> 00:05:34,645
selecting Kotlin, and Configure Kotlin Plugin Updates.

137
00:05:36,100 --> 00:05:38,070
And that will normally tell you

138
00:05:38,070 --> 00:05:39,083
whether there's a new version.

139
00:05:39,083 --> 00:05:41,590
You can see 1.2.71 is the current Kotlin version,

140
00:05:41,590 --> 00:05:43,350
which gives us a hint that we're a bit behind

141
00:05:43,350 --> 00:05:44,650
even though that's the plugin,

142
00:05:44,650 --> 00:05:48,460
but also a new release 1.3.1 is available.

143
00:05:48,460 --> 00:05:51,810
So what we should be able to do is come back down here

144
00:05:51,810 --> 00:05:56,460
and select 1.3.10

145
00:05:57,390 --> 00:05:58,500
and update it that way.

146
00:05:58,500 --> 00:06:00,000
So let's go ahead and do that.

147
00:06:01,580 --> 00:06:03,610
Then we'll need to go back after this

148
00:06:03,610 --> 00:06:05,320
and update the Kotlin plugin.

149
00:06:05,320 --> 00:06:07,350
Because remember, there's two parts to this now.

150
00:06:07,350 --> 00:06:08,470
There's the Kotlin plugin,

151
00:06:08,470 --> 00:06:10,130
but there's also the Kotlin compiler.

152
00:06:10,130 --> 00:06:11,250
So we're actually updating both,

153
00:06:11,250 --> 00:06:14,650
which are usually separate steps.

154
00:06:14,650 --> 00:06:16,170
I know we haven't talked about it a lot,

155
00:06:16,170 --> 00:06:20,120
but Gradle is the build tool that comes with Android Studio,

156
00:06:20,120 --> 00:06:23,070
and it's not just for Android Studio projects.

157
00:06:23,070 --> 00:06:25,732
It works very well for lots of different languages,

158
00:06:25,732 --> 00:06:28,890
and is just a great build tool.

159
00:06:28,890 --> 00:06:31,390
And obviously it's pretty good because that's why

160
00:06:31,390 --> 00:06:33,667
Google have decided to include it or bundle it

161
00:06:33,667 --> 00:06:35,572
with Android Studio.

162
00:06:35,572 --> 00:06:38,290
All right, so a couple of things have come up here now.

163
00:06:38,290 --> 00:06:40,280
Standard library, it's telling us that it's going

164
00:06:40,280 --> 00:06:41,770
to update it and the language version

165
00:06:41,770 --> 00:06:43,610
is updating it to 1.3 as well.

166
00:06:43,610 --> 00:06:44,873
I'm gonna click on Migrate,

167
00:06:45,871 --> 00:06:47,460
Whole project.

168
00:06:47,460 --> 00:06:49,530
And remember, we've got that other note there

169
00:06:49,530 --> 00:06:51,330
in the event log about updating the Kotlin plugin,

170
00:06:51,330 --> 00:06:52,970
which we'll do that shortly.

171
00:06:52,970 --> 00:06:54,660
Usually good when you're updating

172
00:06:54,660 --> 00:06:57,510
not to try and update too many things at once.

173
00:06:57,510 --> 00:06:59,220
It's just trying to let one thing finish

174
00:06:59,220 --> 00:07:01,740
before proceeding to the next step.

175
00:07:01,740 --> 00:07:02,960
All right, so next, then we've done that.

176
00:07:02,960 --> 00:07:05,300
We'll go back into Tools menu, Kotlin,

177
00:07:05,300 --> 00:07:07,012
Configure Kotlin Plugin Updates.

178
00:07:07,012 --> 00:07:10,000
This time what we'll do is we'll instal now

179
00:07:11,770 --> 00:07:15,533
the new version of Kotlin, the Kotlin plugin, rather.

180
00:07:18,420 --> 00:07:20,180
And plugin will be activated after reset.

181
00:07:20,180 --> 00:07:21,457
So I'm gonna click on OK there.

182
00:07:21,457 --> 00:07:23,853
I'm gonna allow Android Studio to restart.

183
00:07:34,989 --> 00:07:36,190
We still got some things that need updating,

184
00:07:36,190 --> 00:07:37,720
but we'll talk about those a little bit later.

185
00:07:37,720 --> 00:07:38,870
We'll close it for now.

186
00:07:41,600 --> 00:07:43,730
What we have got, though, is a clean build.

187
00:07:43,730 --> 00:07:45,300
And there's nothing in there indicating

188
00:07:45,300 --> 00:07:46,750
that anything needs to be updated anymore,

189
00:07:46,750 --> 00:07:47,910
so that's good.

190
00:07:47,910 --> 00:07:50,790
Now that we've done that that's the projects build Gradle.

191
00:07:50,790 --> 00:07:53,350
The next one we wanna do is have a look at our module

192
00:07:53,350 --> 00:07:55,950
in our build Gradle, which is basically

193
00:07:55,950 --> 00:07:59,340
the build Gradle script for our app, for Task Timer.

194
00:07:59,340 --> 00:08:01,120
So let's have a look at that.

195
00:08:01,120 --> 00:08:02,880
Now that needs some updating.

196
00:08:02,880 --> 00:08:05,440
Firstly we've updated to a new version of the Android SDK,

197
00:08:05,440 --> 00:08:08,690
so let's change 27 to 28.

198
00:08:08,690 --> 00:08:12,909
Let's also change the target SDK to 28 as well.

199
00:08:12,909 --> 00:08:14,960
Now there's no longer any need

200
00:08:14,960 --> 00:08:17,530
to specify build tools version.

201
00:08:17,530 --> 00:08:20,970
So if you've got an entry for build tools version

202
00:08:20,970 --> 00:08:22,410
you can comment that out or delete it.

203
00:08:22,410 --> 00:08:25,053
But you can see in my case I haven't actually got that.

204
00:08:26,260 --> 00:08:27,430
All right, so I've made those changes.

205
00:08:27,430 --> 00:08:30,100
We are not gonna sync yet because you can see by doing that

206
00:08:30,100 --> 00:08:31,350
we've got some other issues here,

207
00:08:31,350 --> 00:08:33,190
and basically it's now saying that

208
00:08:33,190 --> 00:08:36,470
because you've updated the Android SDK you shouldn't

209
00:08:36,470 --> 00:08:39,371
be using an older version of the support libraries.

210
00:08:39,371 --> 00:08:42,720
So basically the support library shouldn't be different

211
00:08:42,720 --> 00:08:44,110
to the compiler SDK version,

212
00:08:44,110 --> 00:08:48,252
which of course we've changed up here to SDK 28.

213
00:08:48,252 --> 00:08:50,460
So I'm gonna change that to 28.

214
00:08:50,460 --> 00:08:52,470
When in doubt as to what version

215
00:08:52,470 --> 00:08:55,440
just go with 0.0 which should always be there.

216
00:08:55,440 --> 00:08:57,846
And if there is a version that's been updated after that,

217
00:08:57,846 --> 00:09:00,210
then you'll actually get a message here

218
00:09:00,210 --> 00:09:01,985
that there's a later version,

219
00:09:01,985 --> 00:09:04,486
and you can hover over it as you saw me do previously

220
00:09:04,486 --> 00:09:06,110
to get whatever the version is.

221
00:09:06,110 --> 00:09:07,970
In fact, I'll show you that shortly.

222
00:09:07,970 --> 00:09:10,545
I'll change those three, but this constraint-layout

223
00:09:10,545 --> 00:09:12,839
is wanting to be updated, we get a measure similar to that

224
00:09:12,839 --> 00:09:14,730
and it's saying here that 1.1.3 is available.

225
00:09:14,730 --> 00:09:16,280
So I'm gonna change that to 1.3

226
00:09:17,750 --> 00:09:20,070
and we're going to sync now.

227
00:09:20,070 --> 00:09:22,230
And that should update our application now

228
00:09:22,230 --> 00:09:25,310
to take advantage of all the latest versions

229
00:09:25,310 --> 00:09:27,000
of the various support libraries

230
00:09:27,000 --> 00:09:31,023
as well as the constraint-layout version for API 28.

231
00:09:32,440 --> 00:09:34,520
The other thing you may get is a message.

232
00:09:34,520 --> 00:09:36,510
You may get a tool tip saying you can configure Gradle

233
00:09:36,510 --> 00:09:38,810
wrapper to use distribution with sources.

234
00:09:38,810 --> 00:09:40,400
That's usually a good thing to do.

235
00:09:40,400 --> 00:09:42,110
If there's a bug it can pop up sometimes.

236
00:09:42,110 --> 00:09:44,790
You can click on hide the tip if it comes up more than once,

237
00:09:44,790 --> 00:09:47,170
depending on your version of Android Studio,

238
00:09:47,170 --> 00:09:50,100
you might find that that will come up a few times.

239
00:09:50,100 --> 00:09:51,670
All right, I can see now at this point

240
00:09:51,670 --> 00:09:52,880
we've actually fixed all those errors

241
00:09:52,880 --> 00:09:57,150
and we've now configured ourselves to use Android SDK 28,

242
00:09:57,150 --> 00:09:59,660
and we've updated everything to the latest versions

243
00:09:59,660 --> 00:10:01,964
of the various support libraries.

244
00:10:01,964 --> 00:10:04,060
Now if we just quickly go in as a final check

245
00:10:04,060 --> 00:10:05,890
to go into main activity,

246
00:10:05,890 --> 00:10:07,330
just to make sure it's not showing an error there

247
00:10:07,330 --> 00:10:10,420
and I'll just close this down so we've got a bit more space.

248
00:10:10,420 --> 00:10:13,639
Now this may or may not be showing an error.

249
00:10:13,639 --> 00:10:18,270
If you see an input there for android.app.fragment

250
00:10:18,270 --> 00:10:20,060
then you'll wanna delete that,

251
00:10:20,060 --> 00:10:21,480
and that's because it'll be,

252
00:10:21,480 --> 00:10:23,750
if you've got an error it'll be importing fragment

253
00:10:23,750 --> 00:10:25,686
from the framework android.app.framework

254
00:10:25,686 --> 00:10:28,000
as well as from the support library,

255
00:10:28,000 --> 00:10:31,690
android.support.v4.app.fragment.

256
00:10:31,690 --> 00:10:33,250
And you can see on line five that's the second one,

257
00:10:33,250 --> 00:10:35,200
the one I've got in my project.

258
00:10:35,200 --> 00:10:37,260
So if you happen to get an error delete the other one,

259
00:10:37,260 --> 00:10:39,023
the android.app.fragment.

260
00:10:39,900 --> 00:10:40,960
All right, so there's no more errors

261
00:10:40,960 --> 00:10:44,070
and we can continue on with Task Timer in the next video.

262
00:10:44,070 --> 00:10:45,830
But before I finish you may have heard that Google

263
00:10:45,830 --> 00:10:48,500
are moving their support libraries and a load of other stuff

264
00:10:48,500 --> 00:10:50,260
into Android X.

265
00:10:50,260 --> 00:10:52,080
Android Studio 3.2 and above

266
00:10:52,080 --> 00:10:53,706
will convert your project for you.

267
00:10:53,706 --> 00:10:55,250
There's an option to migrate

268
00:10:55,250 --> 00:10:57,283
to Android X on the Refactor menu.

269
00:11:00,026 --> 00:11:01,090
You can see that option there.

270
00:11:01,090 --> 00:11:02,120
But we're not gonna do that yet,

271
00:11:02,120 --> 00:11:03,830
and the reason that we're not doing it

272
00:11:03,830 --> 00:11:05,410
is because the Android X libraries

273
00:11:05,410 --> 00:11:07,860
are still in alpha/beta.

274
00:11:07,860 --> 00:11:09,470
And that means that they haven't got as far yet

275
00:11:09,470 --> 00:11:11,330
as releasing your production version,

276
00:11:11,330 --> 00:11:13,240
and as such there'll still be bugs present.

277
00:11:13,240 --> 00:11:16,120
And we suggest not using alpha and beta versions

278
00:11:16,120 --> 00:11:18,050
of any library because generally speaking

279
00:11:18,050 --> 00:11:20,460
you won't know if any problems that are coming up

280
00:11:20,460 --> 00:11:23,210
are in your code or in the libraries.

281
00:11:23,210 --> 00:11:24,470
All right, so this has been a long video

282
00:11:24,470 --> 00:11:26,299
so I'll end it here.

283
00:11:26,299 --> 00:11:27,890
In the next one we'll move back to updating,

284
00:11:27,890 --> 00:11:32,200
or move back to working more on the Task Timer application.

285
00:11:32,200 --> 00:11:33,500
See you in the next video.

