- Before creating your first Android Studio
project, you'll need to make sure
you've set up some basic software.
As I've described previously, you'll need
the Java Development Kit, or JDK, from Oracle.
You also need to have installed and updated Android Studio.
If you haven't gone through these steps yet,
stop watching this video, and go back to the
previous videos that describe how to set up the software.
In this course, I'm using Android Studio 1.4,
and I'm working with the version of the SDK
for Android 6.0, or Marshmallow,
which is known for the developer as API level 23.
To create your first app, start in the
Android Studio welcome screen,
and click Start a New Android Studio Project.
I'm going to name my application Hello World,
and then I'll set the company domain
starting with example.com.
Any app that belongs to this particular
domain can't be submitted to the Google Play Store,
and so by using this, I'll make sure that
it's always marked as a sample application.
But my particular app is going to be
a clothing catalogue for a fictional
company named H Plus Sport, so I'm going to set
the complete company name as hsport.example.com.
That generates a package name,
showed in dim characters below.
The package name is also known as
the app identifier, and it provides
a global unique identity for the app,
so only one app for each identity
can be hosted on the Google Play Store
or other distribution channels.
If you like, you can customize the
package name by clicking the Edit link,
and I'm going to change my actual
package name to hsport.catalog,
and I'll use this same package name
for all of the sample apps throughout this course,
so that when I install a new app,
it'll replace the old one on any particular device,
and I won't end up with a whole bunch
of different apps on the devices.
Next I'll indicate where I'm creating my project on disk.
The default is a folder named Android Studio Projects
underneath my home folder.
This is just a folder.
It's not like an Eclipse workspace that contains
configuration information.
And if you prefer, you can place the project
anywhere else on your hard disk.
I'll Accept that location and click Next.
On this screen, I'm asked what my Minimum SDK will be.
The default is typically API 15,
or Android 4.0.3 (IceCreamSandwich).
If you want to support all of the current devices
that are being tracked in the Google Play Store,
you could instead choose API 8,
for Android 2.2 or Froyo.
But that would require a lot more development and testing
on your part.
You can click on this link to help you choose,
but this information, in my experience,
is usually a little bit out of date.
To find better, more up-to-date information
about current penetration statistics
for different versions of Android,
go to a browser.
This is the screen where you can find out current usage
rates on the Google Play Store.
And you'll see that as of this date,
Froyo has a tiny, tiny percentage of the market,
and even Android 2.3, Gingerbread,
has a very small percentage.
If you eliminate support for these versions of Android,
you can save yourself a lot of development and testing time.
Also on this screen, you're asked which form factors,
or what kind of devices you're going to support.
The default is building an app for phone and tablet.
And that's all I'm going to choose for my app.
I'm not going to build apps for ware, TV, or Android Auto.
So I'll set my minimum SDK to API 15,
and click Next.
By default, your app will have a single activity,
or screen,
and the default selection is a template named
Blank Activity.
This will create that Single Activity
and it will display some simple text.
It will also present a fairly sophisticated control
called a Floating Action Button,
and add Java code to react when the user presses the button.
If you want to start with a much simpler app,
choose the Empty Activity template
and you'll only get a little bit of text.
But I'll choose Blank Activity and click Next again.
This screen asks for something called an Activity Name,
and this will be the name of a Java class,
and a related layout, which is an XML file
that describes the appearance of this screen.
There's also a title,
and I'm going to change the Title to Hello World,
and a Menu Resource Name,
and this is an XML file that describes an Options menu.
If you prefer, you can create your screen using a fragment,
and this will let you easily adapt your application
to tablets or other size devices.
But I'll leave that option unchecked to keep things
a little bit simpler,
and I'll click Finish.
That creates the project.
When you see the Activity Design screen open and display
the app's first screen,
you're ready to run the app for the first time,
but if this is the first time you've gone through this
process, it might take awhile to get here.
Down at the bottom of the screen,
you'll see some messages indicating that content
is being indexed,
and this process can take a few minutes,
so step away from the computer
and then come back to it a little bit later.
The next time you create a project,
I promise it'll go a lot faster.
Also, if you see any errors,
once again wait for all that processing to finish
before you try to fix it,
but if you still see errors there,
go to the menu and choose Build,
and then Clean Project.
And that will delete any artifacts that were initially
created and completely rebuild the project
and this will frequently fix any issues that appear
the first time that you create the project.
So now, you've created the app
and you're ready to test it on a device.
You'll need either a physical device that's configured
for testing, or a virtual device that you can use
in the Android emulator,
and I'll describe how to get started with both options
in the next couple of videos.
-end-