Once you have installed Android Studio you are ready to make your first Android app. Don't worry that you don't know much ye...
Starting Android Studio
First you need to start Android Studio. Find the Android Studio launch file (.exe on Windows) and start Android Studio. You will either have a shortcut in your Windows Start menu, on your desktop, or in the directory into which you installed Android Studio.When you start Android Studio it may tell you that there are updates available for Android Studio. That is fine. Accept to download and install the updates so you have the latest version of Android Studio.
Creating a New Android Studio Project
If this is the first time you have opened Android Studio (or if you close an open project) you will be presented with this screen. Click on the "New Project" menu option in the right side of the dialog.
If you already have an Android project open, you can create a new project via the "File" menu at the top left corner of the open window. Choose "New Project...".
Application Name, Company Domain, Project Location
Inside the "new project" dialog you have to enter three values: Application name, Company Domain, and project location.
Inside the "new project" dialog you have to enter three values: Application name, Company Domain, and project location.
The application name is whatever name you would like your Android app to have. In this case just call it "My First Android App".
The company domain name is used to uniquely identify your app. Thus, even if two different companies create Android apps with the same name, you can still see which is which because their company domain names will be different. If you have a company, type in the company's domain name in reverse (e.g. com.company). If you have no company, you can just choose a fictive company domain name. To make this first app it doesn't matter so much. Only if you plan to release it to Google Play, then the company domain name matters.
The project location is a directory on your hard drive where you want to put all files related to this Android Studio project. I would recommend that you create an android-studio-projects directory in which you store all your Android Studio projects. Under that directory each project will have its own subdirectory. Thus, the project location for this first project could be:
D:\data\projects\android-studio-projects\MyFirstApplication
Once you have set the application name, company domain and project location, click on the "Next" button in the lower right corner of the dialog.
Selecting Form Factors
The second screen in the "New Project" dialog asks you to select what form factors your app will run on. Form factors means screen sizes and device types. Just select the "Phone and Tablet" option and leave the rest unselected. Then click the "Next" button.
The company domain name is used to uniquely identify your app. Thus, even if two different companies create Android apps with the same name, you can still see which is which because their company domain names will be different. If you have a company, type in the company's domain name in reverse (e.g. com.company). If you have no company, you can just choose a fictive company domain name. To make this first app it doesn't matter so much. Only if you plan to release it to Google Play, then the company domain name matters.
The project location is a directory on your hard drive where you want to put all files related to this Android Studio project. I would recommend that you create an android-studio-projects directory in which you store all your Android Studio projects. Under that directory each project will have its own subdirectory. Thus, the project location for this first project could be:
D:\data\projects\android-studio-projects\MyFirstApplication
Once you have set the application name, company domain and project location, click on the "Next" button in the lower right corner of the dialog.
Selecting Form Factors
The second screen in the "New Project" dialog asks you to select what form factors your app will run on. Form factors means screen sizes and device types. Just select the "Phone and Tablet" option and leave the rest unselected. Then click the "Next" button.
Add An Activity
The third screen in the "New Project" dialog asks you to add an activity to your Android app. Activities are similar to windows in an desktop application. Thus, you have to choose what "window" or "screen" (activity) that your Android app will use. An Android app can use more than one activity (switching between "screens" / activities), but in this case just select "Blank Activity". Then click the "Next" button.
The third screen in the "New Project" dialog asks you to add an activity to your Android app. Activities are similar to windows in an desktop application. Thus, you have to choose what "window" or "screen" (activity) that your Android app will use. An Android app can use more than one activity (switching between "screens" / activities), but in this case just select "Blank Activity". Then click the "Next" button.
Choose Activity Options
The fourth screen in the "New Project" dialog asks you to choose option for your new file (activity). You have to choose an activity name, layout name and a title. The dialog has already suggested some names. Just leave these suggestions in the input fields and click the "Finish" button.
When you click the "Finish" button Android Studio takes a bit of time to create your new project. When it is finished it will open your new project in Android Studio.
The fourth screen in the "New Project" dialog asks you to choose option for your new file (activity). You have to choose an activity name, layout name and a title. The dialog has already suggested some names. Just leave these suggestions in the input fields and click the "Finish" button.
When you click the "Finish" button Android Studio takes a bit of time to create your new project. When it is finished it will open your new project in Android Studio.
Running the App
You are now ready to run your first Android app on your Android phone.
Enable Developer Options
First you need enable developer options on your device. The developer options enable you to connect the device to your computer via a USB cable, and run your apps directly on your phone via Android Studio. This is nice when testing out how your app works on a real phone.
Enabling developer options in Android 4.2 and later can be a bit tricky. The developer options are hidden. But, this short video explains how to enable developer options in Android 4.2 or later.
Install USB Drivers
If you are developing on Windows you may have to install some USB drivers for your device on your Windows computer. How that is done is explained in Android's guide to install USB drivers.
Plugin Your Device
Now plugin your Android device. Connect it to your computer with a USB cable. On the device, in the notifications bar it should say "connected as a media device". That is the right connection type.
After a short while the phone should show a dialog asking if you want to allow USB debugging on the phone. The dialog will show you the computer's RSA key plus some more information. Click the "OK" button. Now the device is connected to Android Studio. If you by accident click "Cancel" or click outside the dialog so it disappears, disconnect your Android device and re-connect it again. That should make the dialog show up again.
Run the App
In Android Studio's "Run" menu select " Run 'app' ".
After a short while Android Studio shows you a dialog where you can choose what device to run your Android app on. You should see your connected device in the list. Choose your device and click the "OK" button.
Look at your Android device. It should now be running a basic app with the title "My First Application" (or whatever name you gave it) and with the text "Hello world!" on the screen. This is the basic app that Android Studio created for you when you created the project. You are now ready to modify the project to turn the app into whatever app you want to develop.
You can also run your new Android app via the "Run" button in the toolbar. Here is where the "Run" button is located:
COMMENTS