(light music)
(computer keys clicking)
Before we continue with the TaskTimer App,
let's review what happens when various parts
of Android Studio as well as the Android SDK get updated.
So I've started up Android Studio
and you can see that we have got
some updates waiting for us.
But I also wanna show you the process
of updating the Android SDK.
So we're going to Configure, and we'll select SDK Manager.
And when I do that you can see at the moment now
we've got a new version, Android 9.0 Pie.
So that's our new release.
And new release comes through once or twice a year.
We had Android 8 last year and then an 8.1 update.
So what we're gonna do is update to Android 9.
So I'm gonna click on that button, the Android 9.
And we're gonna click on Show Package Details.
It tells us what parts of the Android 9 update we can take.
I'm gonna click on Android SDK Platform 28 and Sources.
And the other thing you should do
is to select a system image that you'll actually be using.
So or you can choose either say the Google API System image,
or Google Play one, we've talked about the differences
between those two.
I'm also gonna grab the Intel x86.
But you can grab whichever ones you need.
So that's number one.
Secondly, in SDK Tools, same thing,
Show Package Details.
We've quite older versions that were previously installed.
I'm gonna grab the latest version as well,
which in this case is 28.0.3.
And we're gonna click on OK now that I've done that.
It gives us an update on what it's about to do.
I'm gonna click on OK.
All right, so that's now gonna download
and instal those things.
So I will just fast forward this video
so you don't have to wait too long
while it downloads and instals everything,
and we'll come back once that's complete.
All right, so you can see that we've now completed that
so I'm gonna click on Finish.
And that part has been updated.
We can go back into Configure, SDK Manager again.
We can see that Android 9 is now showing as being updated.
We've still got the older version.
I'm gonna leave that there for now,
and SDK Tools.
We're doing a later version.
So that's a good thing to have a recap
on every now and again.
But the next thing we'll do now is go into Task Timer
now that we've updated.
So things get updated on a regular basis,
and I know we've covered some of this stuff before,
but recapping it, I think, is a good idea
because it's something that you'll need
to do fairly often as Google update
to support libraries and the Gradle build system.
And there's also updates to the Kotlin language
and the Kotlin plugin that Android Studio uses.
So again, just a good recap
of the various steps that are needed.
So you can see that what's happened at the moment
is that we've been told to take advantage
of the latest version of Gradle and upgrade to 4.6.
That number might be different
depending on when you're watching this video.
For now I'm gonna click on Remind me tomorrow
just to show you an alternate way.
I wanna actually show you what it's actually gonna change.
Normally you would actually click Update there.
So I'm gonna click on Remind me tomorrow.
And we should find a Gradle file to build.
And you can see, in fact,
we've got an error at the top here,
Kotlin not configured.
So it did actually complete a build,
but obviously with Kotlin not configured
we've got various errors showing through here,
which we need to fix.
All right, so how would we do this manually?
Well first we got that message about Gradle.
We can actually come over here to Gradle Scripts.
And there's this gradle-wrapper.properties.
Double click that to open it.
Sometimes that gets updated automatically.
If you do get that earlier dialogue you can choose update,
but here what I'm gonna do is manually change it.
I'm gonna update it to 4.6 just
to show you an alternate way of doing it.
I'm gonna sync now.
And that's going to actually
download the new version of Gradle, that new version.
You can see down at the bottom
it's busily downloading things.
For the first time when you select a new version of Gradle
it goes through that process.
And just another reminder here is that you can
create a new project and check out
all the equivalent files in there,
comparing it to what you've currently opened.
And this is basically a good process to go through
if you've got an app that you haven't updated
for a long time, you haven't opened in Android Studio
for a long time when you want to update it
to the latest version of the various support libraries
and the Android SDK itself.
So we'll just fast forward through this
and wait for it to finish.
All right so you can see that's now finished,
and we've now got a successful build there,
but if you go back to our source code
we can also see now that's looking a bit healthier.
We haven't got any errors anymore.
So so far so good.
The next thing to look at is to go back now
into our regular projects build Gradle file.
So build.gradle for our project.
Open that up and have a look.
And you can see at the moment we're using 1.2.51,
the version of Kotlin.
But also notice here the gradle plugin wants to be updated.
Now that we've actually run the, or updated to 4.6,
it's telling us there's an upgrade available.
So I'm actually gonna change it
to what it's asking for there, which is 3.2.1.
And I can do that by just editing that file,
3.2.1.
But the other thing is the version of Kotlin is updated,
and there's no indication here that it has.
One way of finding that out is going into the Tools menu,
selecting Kotlin, and Configure Kotlin Plugin Updates.
And that will normally tell you
whether there's a new version.
You can see 1.2.71 is the current Kotlin version,
which gives us a hint that we're a bit behind
even though that's the plugin,
but also a new release 1.3.1 is available.
So what we should be able to do is come back down here
and select 1.3.10
and update it that way.
So let's go ahead and do that.
Then we'll need to go back after this
and update the Kotlin plugin.
Because remember, there's two parts to this now.
There's the Kotlin plugin,
but there's also the Kotlin compiler.
So we're actually updating both,
which are usually separate steps.
I know we haven't talked about it a lot,
but Gradle is the build tool that comes with Android Studio,
and it's not just for Android Studio projects.
It works very well for lots of different languages,
and is just a great build tool.
And obviously it's pretty good because that's why
Google have decided to include it or bundle it
with Android Studio.
All right, so a couple of things have come up here now.
Standard library, it's telling us that it's going
to update it and the language version
is updating it to 1.3 as well.
I'm gonna click on Migrate,
Whole project.
And remember, we've got that other note there
in the event log about updating the Kotlin plugin,
which we'll do that shortly.
Usually good when you're updating
not to try and update too many things at once.
It's just trying to let one thing finish
before proceeding to the next step.
All right, so next, then we've done that.
We'll go back into Tools menu, Kotlin,
Configure Kotlin Plugin Updates.
This time what we'll do is we'll instal now
the new version of Kotlin, the Kotlin plugin, rather.
And plugin will be activated after reset.
So I'm gonna click on OK there.
I'm gonna allow Android Studio to restart.
We still got some things that need updating,
but we'll talk about those a little bit later.
We'll close it for now.
What we have got, though, is a clean build.
And there's nothing in there indicating
that anything needs to be updated anymore,
so that's good.
Now that we've done that that's the projects build Gradle.
The next one we wanna do is have a look at our module
in our build Gradle, which is basically
the build Gradle script for our app, for Task Timer.
So let's have a look at that.
Now that needs some updating.
Firstly we've updated to a new version of the Android SDK,
so let's change 27 to 28.
Let's also change the target SDK to 28 as well.
Now there's no longer any need
to specify build tools version.
So if you've got an entry for build tools version
you can comment that out or delete it.
But you can see in my case I haven't actually got that.
All right, so I've made those changes.
We are not gonna sync yet because you can see by doing that
we've got some other issues here,
and basically it's now saying that
because you've updated the Android SDK you shouldn't
be using an older version of the support libraries.
So basically the support library shouldn't be different
to the compiler SDK version,
which of course we've changed up here to SDK 28.
So I'm gonna change that to 28.
When in doubt as to what version
just go with 0.0 which should always be there.
And if there is a version that's been updated after that,
then you'll actually get a message here
that there's a later version,
and you can hover over it as you saw me do previously
to get whatever the version is.
In fact, I'll show you that shortly.
I'll change those three, but this constraint-layout
is wanting to be updated, we get a measure similar to that
and it's saying here that 1.1.3 is available.
So I'm gonna change that to 1.3
and we're going to sync now.
And that should update our application now
to take advantage of all the latest versions
of the various support libraries
as well as the constraint-layout version for API 28.
The other thing you may get is a message.
You may get a tool tip saying you can configure Gradle
wrapper to use distribution with sources.
That's usually a good thing to do.
If there's a bug it can pop up sometimes.
You can click on hide the tip if it comes up more than once,
depending on your version of Android Studio,
you might find that that will come up a few times.
All right, I can see now at this point
we've actually fixed all those errors
and we've now configured ourselves to use Android SDK 28,
and we've updated everything to the latest versions
of the various support libraries.
Now if we just quickly go in as a final check
to go into main activity,
just to make sure it's not showing an error there
and I'll just close this down so we've got a bit more space.
Now this may or may not be showing an error.
If you see an input there for android.app.fragment
then you'll wanna delete that,
and that's because it'll be,
if you've got an error it'll be importing fragment
from the framework android.app.framework
as well as from the support library,
android.support.v4.app.fragment.
And you can see on line five that's the second one,
the one I've got in my project.
So if you happen to get an error delete the other one,
the android.app.fragment.
All right, so there's no more errors
and we can continue on with Task Timer in the next video.
But before I finish you may have heard that Google
are moving their support libraries and a load of other stuff
into Android X.
Android Studio 3.2 and above
will convert your project for you.
There's an option to migrate
to Android X on the Refactor menu.
You can see that option there.
But we're not gonna do that yet,
and the reason that we're not doing it
is because the Android X libraries
are still in alpha/beta.
And that means that they haven't got as far yet
as releasing your production version,
and as such there'll still be bugs present.
And we suggest not using alpha and beta versions
of any library because generally speaking
you won't know if any problems that are coming up
are in your code or in the libraries.
All right, so this has been a long video
so I'll end it here.
In the next one we'll move back to updating,
or move back to working more on the Task Timer application.
See you in the next video.