Learning Android in 30 Days. Tutorial 1 of 30: Basic setup

Hi and welcome.

In this series of 30 tutorials, we will be building a weather app using as many features in Android as possible so you can use them as mini-tutorials for beginers or for specific topics for advanced developers.

With no further introduction let's start with day 1.

After installing Android Studio let's start if for the first time. and begin by selecting Start a new Android Studio project.
 
The first screen you will see after executing Android Studio

After, the IDE will prompt a wizard that we are going to use to start faster (We want to get this done in 30 days!).

The first thing we are going to select is the name of the app. The name will be the display label in the icon of the app. There is no need to define the final name in the first step as you can change it later.

If you feel comfortable, just use the same as mine as shown.

You can change the application name after if you wish.

Now let's select the target. You can choose from many different devices like Android TV, Google Glass, Tablets, Phones and Wear (smartwatches).

In this tutorial, we will focus on Android Phone and Tablets architecture but we could do another one for Wear and TV.

Make sure you select only Phone and Tablet and select the Minimum SDK as 2.3.3.


Select 2.3.3 Gingerbread and only Phone and Tablet

Next, select an Empty Activity to start in a blank space with no distractions. As you can see we will understand that an Activity sums to be the logical part of the app; the Java code will be written there and we will define the behavior of our app.

There are many other templates but now we will focus on a blank space

Finally, the last part will be naming the Activity. The name of the Activity will have no effect on our app but we will do well following Java naming conventions. Our Activity is a Class and therefore, it must be named using Uppercase in the first word.

Mark the box for Generate Layout File and leave the name suggestion as shown below.

The Activity name is the name of the Java Class


After you click finish, Android Studio will start to generate the project and building the default resources. Depending on your computer it could take some minutes or about 30 seconds.


Now that we have our project ready for the test we need a device. You can use your own Android device but if you don't, there is also a virtual device option.

Setting up you own phone.

 

In your device navigate to Settings > About phone. You will find listed Build number at the bottom. Tap it several times until a message displays with "You are now a developer".



Tap several times on Build number


When you go back to the previous menu, you will see listed Developer options. Select it to enter the menu.

Now Developer options is in your System menu.


You will find Enable USB Debugging. Make sure its turned on.

Enable USB debugging.


Once you are done with that you just need to plug your phone with a USB cable to your computer. Notice that a damaged cable could cause connectivity problems so make sure is in good state.

Once is pluged, your phone may prompt a message like the following.

Trust your computer always.


Make sure you mark Always allow from this computer and tap OK. Now your device is ready.

Setting up a virtual device.

 

If you want to skip configuring a virtual device because you will use your phone you can click here to go to the next step but I strongly encourage you to stay here since there is no harm in using a virtual device.

Using a virtual device will allow you to create different devices with different screen sizes, memory and pixel density so you can try multiple configurations for your app.

To use a virtual device you must first create one. Select the AVD button in the Android Studio menu



Select the second icon from the left. AVD Manager.
 Once the AVD dialog opens, select Create Virtual Device...




Select Create Virtual Device.

Select any skin you would like to apply (I recommend using Nexus since it can be compared to many other devices) and then click Next.




Select any skin you like. Nexus' are mostly a standard.


Now Android Studio will check for any SDK available for that device and since our installation is new we probably would have to download one of the many available. I'm using right now a Lollipop x86_64 but there is no big difference between many other unless Android Studio suggests a specific one. Pick one and click Next.

Select Lollipop x86_64.
The Component Installer will download the Android image and will install it somewhere, when its done you will have to click on Finish.

Wait for the Android image to download and click Finish.

You can see that you can select the downloaded image and click Next. Add a name for your device and use the suggested configuration. As you can see you can set up many different configutations but we will take as it is since we dont need a special setting for running our app. Once you are happy with your settings cick on Finish.

Select the downloaded image and click Next.
Click again on AVD and you will see your recently created device listed. The only thing you need is to click in its respective Start button and wait for the AVD to mount the image. The first time you do this could take a few minutes depending on your computer specs.

Select a Virtual device to launch.



Android Virtual Device running.

First run.

If you are using your phone make sure its plugged and if you created a virtual device launch it. Click on Run and select the detected device in the dialog.

Select Run.

All of the compatible devices will be listed here. Pick one.


Once it's completed you will see your first application running in the device you selected.

So far our app does nothing but to show the pre-built message but it's important to notice that this app is now installed on the device. If you navigate to the drawer you will see it there among its peers ready to be launched whenever you tap on the default icon that Android Studio made for us.

The bell rings.

 

Ok, we probably skipped a lot of important topics like the minimum SDK and an overview of an Activity but we will be covering those topics in the remaining 29 days.

Keep this project for the tutorial as we will use every piece of code and resource to complete the lessons. If you had troubles keeping this tutorial add a comment in the section below and don't forget to share it with your colleagues.

Thank you for reading!

Next tutorial.


No comments:

Post a Comment