In this video, we're going to create our
very first Android application. So if you
haven't already start to render a studio
application and if you're on a Mac you
can go into the Applications folder to
do that and double-click your Android
studio and if you're on a Windows
machine you can just go into the start
menu and type Android and click the icon
when it appears. Now Linux you can use
the technique I showed you in that video
to access the Android studio desktop
entry that we created. So once you've
started Android studio we're going to
create our first application by clicking
on start a new Android studio project.
Now once you do that a series of screens
will appear to ask you for some basic
information about the project you want
to create the first screen asks you for
the application name and we're going to
keep it simple and call our first
application HelloWorld. Now the next part
is what might be a bit confusing the
company domain, so Android applications
use the concept of a package name to
make sure that your application
reference is unique across the world now
that's a Java convention but it's used
for all sorts of other things as well
the internet couldn't function if domain
names weren't unique worldwide now the
reason that it needs to be unique is
when you eventually go to upload your
code to the Google Play Store to make it
available for sale you need to have a
unique identifier that's not used by
anyone else. So what Google suggests you
do is type your company - main name so
in my case I'm going to use my domain
name which is Learn Programming dot
Academy, if I delete this and type it in
again as I'm typing it down the bottom
the package the name is getting updated
learn programming dot academy, now
Android studio uses this with verse
domain name to create the package,
so I'll type in Learn Programming dot
Academy but you came back and said
Academy dot Learn Programming dot
hello world. Now the hello world by the
way was a representation of what I typed
in the application name field at the top
more inner space is an all in lowercase.
Now if you haven't got your own domain
name that's okay for training and
testing purposes there's a set of
example domains that have been set aside
for people to use example.com and
example.org at all these example domains
so you could just use example.org
and it'll be
the package name or that example that
hello world for you, if you want more
information you can visite example.org
or example.com in a browser and there's
a link you can actually click when you
get there for more information so you
can literally have anything there but
just do note that once you're creating
your own applications and you're at the
stage of uploading them to the app store
then you need to have a domain name so
you should really make that unique, so at
the moment though I'm going to go ahead
and use mine which I'll be using through
this course learn programming dot
academy. So next you need to find the
location where you're going to start
saving your projects now this is just
like a word processing document in a
sense that you need to choose somewhere
to save them I've really got my
locations to that in this case I'm
putting them in my desktop in a folder
called Android O Kotlin, but so you can
just choose any location by coming over
here and clicking on the three dots the
ellipsis and selecting a folder to store
all your Android programs in and note
that when you do that and choose a
location at the end Android studio will
helpfully add hello world and that will
actually be a subfolder
containing our application in other
words creating a subfolder based our a
subfolder of the Android O Kotlin
folder then ultimately containers hello
world project and as you create lots of
projects and she moves through this
course there's going to be one subfolder
for each of those projects and that's so
that they're neatly separated and you're
not running any risk of actually getting
into difficulties in some way by
overwriting code, so make sure you don't
try to put two projects in the same
folder that's going to cause all sorts
of problems.
Now there's another important setting
here we need to make on the screen so
make sure you tick the include Kotlin
support box that causes android studio to
generate Kotlin code rather than java
code. Now this is the Kotlin version of
the course,
so we definitely want Kotlin here it is
possible by the way to mix Kotlin and
Java in the same project but for our
purposes we want Kotlin to be the
default so make sure that box is ticked
before clicking next and you can see in
my case that is now this next screen it
can be a little bit intimidating at
least the first few times you see it
might be thinking what's all this about.
Well, firstly before I start talking
about minimum SDK these things here they
wear TV Android auto Android things
don't normally be
ticked. Now where is Android
functionality to run Android
applications and things like watches and
so forth in other words wearable devices.
Now the next one TV is for Android TV so
that you can create applications that
work with Android TV and that's the TVs
that are running the Android TV
operating system Android auto well
that's actually yeah for cars
automobiles literally, again it's a
special version that runs on that so you
can create applications for cars and
last but by no means least Android
things enables you to create apps for
for IOT devices now we aren't going to
be targeting any of those in this course
because to actually do them justice we
need to create a course in their own
right for them so you're leaving all
these disabled for this course but the
important thing of this screen is this
minimum SDK talks about here at the top
so what is that well SDK stands for
software development kit which is the
version of the Android software of the
Android operating system the minimum
version that your application is going
to run on now will be dropped down the
list, you go all the way back to Android
we can go all the way back to Android 4
if we wanted to literally a people API
14 Android 4 Ice Cream Sandwich
that's API 14 million a longer
supporting older Android versions so
that's the earliest version we can
choose here now by monitoring the
devices that connect to the Play Store,
Google can track which versions of
Android are still being used and they've
worked out that there really aren't many
devices if any still running versions of
Android before API 14 now that's great
if you want to fully support everything
but by adding support for all versions
of the Android operating system going
right back to version 4 we're limited to
some other functionality we can use and
that's because as new versions of the
Android operating system have come out
Google have updated it and improved it
and added a lot of features so
consequently it's generally not
recommended to go back and say that
you're going to support that minimum
version so it is a bit of a trade-off
between the percentage of people who can
access an older version and the
functionality that you want to have in
your application now as a general rule
I'd suggest that you set your minimum version
to target Android 4.2 this is API 17
which is jellybean then when you select
each version the display updates to show
the percentage of devices that your app
will work on, you can see here that API
17 and higher will include 96% of
devices that are active in the Google
Play Store then that number will
increase as older versions are updated
or replaced but at the time I'm
recording this 96% of all Android
devices active today are using Android
4.2 jelly bean or later. Now there's a
reason I suggest API 17 and that's
because support for right-to-left
languages was included in that version
so you could target in an earlier API
and you've got an API 16 phone that you
want to use for example then probably
would make sense to choose API 16
instead but I'm comfortable saying that
you should use API 17 but I'll also be
showing you how to change that if you
change your mind and decide to support
an earlier version. We'll see how to do
that in a later video but by choosing
API 17 here
anyone who's running an Android version
going right back to Android API 17 or
higher will be able to run the
applications you create and that's again
it's 96% of users if they're running an
older version they won't be able to
download and run the application and
incidentally the ability to set a
minimum SDK is why you don't have to
install all those older Android versions
when we were configuring Android in the
SDK manager so I'm going to talk a bit
more about compatibility later but you
can see the older is decay levels are
available even though we didn't install
all the previous versions all right so
I'm selecting API 17 I'm going to click
on next,
we then get to the template screens that
we've discussed in this section of the
course. Now these are the various
types of projects that you can create by
default with Android studio and as
previously mentioned it'll automatically
add code and layouts for you depending
on which one you choose you know once
again if the exact template isn't
available because perhaps Google have
changed things by the time you're
watching this video, no need to worry so
I'm going to use empty activity here
which is selected for me currently so
just choose the one if that's closest in
appearance if empty activity isn't available
all the names changed, so do that and
click on next and finally just before
Android studio creates the project and
generates the code for us it's asking
for the name of the activity and layout.
Now I am going to be talking about
activities and layouts a bit later but
for now we can just accept the default
names then Android studio is suggesting
and we've already seen how both of these
names are used in the previous videos in
this section, so the suggested names are
fine and quite descriptive so we're
actually going to go with those so
there's also a couple of checkboxes and
normally you'd leave these both checked
this first one generate layout file that
causes Android studio to create a
default layout file from the project
that's the activity underscore main
layout. Now most apps you create would
need at least one layout or they
wouldn't be able to display anything so
you may as well get Android studio to
create the file for you. Now if you're
creating an app that will run as a
service and have no youth and will have
no user interface then you could and
tick that box in the second check box
it's a good idea to keep checked that's
the backwards compatibility check box if
you want ticket your app will only run
on the latest version of Android well I
guess that's not strictly true because
you can't change the specific version
but you'll be targeting a single version
of Android and the app won't work in
earlier versions and then we're going to
be talking about app compat in detail
later so for now please just take my
word for it and I'll leave that box
ticked and then click on finish and you
saw that the progress was updated as
Android studio created the project and
it took a bit of time and then the top
the bottom left-hand corner it says
gradle build finished in two seconds and
you can see we've now got this project
showing on the screen it does take a
while the first time you create an
Android project in Android studio but
the next time you write from that
project it should be a lot quicker and
just a reminder not to try and do too
much until it's finished building the
project expanding the directories in the
project panes okay but editing code or
changing layouts isn't a good idea
until you see that build finished in the
bottom left hand corner now by default
you'll see a tip of the day dialog I've
already disabled it on mine but I mean
come in here and have a look
tip of the day the by default you
tip of the day dialogue pop-up and that
can be interesting
it shows interesting features in Android
studio that can make you more productive
and until you've used Android studio but
it probably won't make a lot of sense
though so I suggest us closing it when
Android studio starts until you've got
more experience with Android studio the
tips can help you become more productive
once they start making sense and if you
want you can stop it appearing which
I've done by unchecking these show tips
on startup check box over here but in
this case I'm just going to close it if
you haven't done that and you want to
see it again go to the help menu and you
can select tip of the day here to bring
a backup all right so let's finish now
and we've got some things that have come
up on the screen sometimes you see a
message that Gradle files have changed
in which case just click on this sync
now button at the top right hand side
of the screen and that should clear the
message and greater will build the
project again and if you're wanting work
greater with it's an open-source build
automation system, so basically pulls
together all the bits of the project to
create the application file that can be
installed on an Android device. Now if
you use external libraries such as the
YouTube API that we'll be using in a
later section of the course then you can
tell Gradle about that and it sorts
everything out for you so you don't
really need to know more about that at
this stage because Android studio runs
Gradle for you when you come to run the
app. Alright so this video is getting a
little bit long, let's end the video here
in the next video we'll continue on our
journey to creating our first app,
I'll see you in the next video.