Build First Application Using Android Studio

Android Studio

 
Android Studio is a new Android development environment based on IntelliJ IDEA. Similar to Eclipse with the ADT Plugin, Android Studio provides integrated Android developer tools for development and debugging. On top of the capabilities you expect from IntelliJ, Android Studio offers:
  • Gradle-based build support.
  • Android-specific refactoring and quick fixes.
  • Lint tools to catch performance, usability, version compatibility and other problems.
  • ProGuard and app-signing capabilities.
  • Template-based wizards to create common Android designs and components.
  • A rich layout editor that allows you to drag-and-drop UI components, preview layouts on multiple screen configurations, and much more.
Android Studio Installation
 
You can download Android Studio from the following Google's Developer's site:
 
http://developer.android.com/sdk/installing/studio.html 
 
To get the installation guide, visit Getting Started With Android Studio.
 
Have an Execution Problem?
 
After following all the necessary steps to install Android Studio, do you encounter a problem running it? I encountered a problem and found a solution that I wrote about that Android Studio was not Starting Up After Installation.
 
The first step towards Application
 
Open Android Studio. That will display the following after initialization.
 
AndroidStudio1.jpg
 
You will see there are 6 tabs there.
  1. New Project
     
    Creates a new project with Android parameters. 

  2. Import Project
     
    Imports Android projects from the same or another workspace. 

  3. Open Project
     
    Open projects from a directory.
     
  4. Check out from Version Control
     
    If your Android Studio was configured with Sub-version then you can check-out with it.
     
  5. Configure
     
    Here you can do plug-ins settings, import-export settings and many more.
     
  6. Documentation and How-Tos
     
    You will get help related to Android Studio, tips, keymap references etcetera.
Step 1: Click on "New Project"
 
This will open the following screen. I have filled it in with the required information. So do so.
 
AndroidStudio2.jpg
 
When you fill in your Application name, in your case the package name will be like "com.example.anstudapp", that I changed to "com.anstud". You can change the package name as you need to.
  1. Application Name
     
    The application name is shown in the Play Store, as well as in the Manage Application list in settings. 

  2. Module Name
     
    The module name is only used by the Android Studio IDE. Generally, the module name is the same as the application name.
     
  3. Package name
     
    The package name is a unique identifier of your application. Carefully choose the package name for real-time applications that will be uploaded to the Play Store. The Play Store will not accept another application with the same package name (that is defined in the AndroidManifest.xml file).
     
  4. Project location
     
    Select the workspace where you want to put this project.
     
  5. Minimum SDK version
     
    Choose the lowest version of the Android SDK that is supported by your application.
     
  6. Target SDK Version
     
    Choose the highest version of Android SDK supported by your application. The Target version is that the Application is known to work with.
     
  7. Compile with
     
    Choose the API to compile your Target SDK.
     
  8. Theme
     
    Select the Base theme of your application.
     
  9. Create Custom Launcher Icon
     
    If you would like to define a custom launcher icon in this wizard, select this option.
     
  10. Create an Activity
     
    If you would like to create an activity from the default selection then check this option.
     
  11. Mark this project as a Library
     
    If you are creating a library then you need to select this option. This project will allow you to refer to another project.
AndroidStudio3.jpg
 
Step 2: Click "Next" to create a custom launcher icon
 
If you have not selected this option in the previous screen then you are not able to define a custom launcher icon and text in this wizard. You can still define it manually after project creation.
 
AndroidStudio4.jpg
 
You can also select "custom image" from Clipart.
 
AndroidStudio5.jpg
 
You can also select the option "Text" to set the launcher text icon as in the following:
 
AndroidStudio6.jpg
 
Step 3: Click "Next" to Define Activity
 
This screen will let you select a default sample activity, like Blank Activity, Full-Screen Activity, and Master/Detail Activity etcetera. If you have not selected this option on the main screen then you are not able to select this default activity. You need to define a new activity in your package yourself.
 
AndroidStudio7.jpg
 
Step 4: Click "Next" to Create the Main Activity
 
You are now at the last step of project creation. Give an Activity name in the field, then give a layout name and if you like, select navigation like "Fixed Tab + Swipe" etcetera then select an option from the drop-down list.
 
AndroidStudio8.jpg
 
Now, click on the "Finish" button to complete this project wizard. This will next configure your new project settings. If "Gradle" is not installed in your disk then this will download all the dependencies before this. So wait until the setup is finished. If the package can't be downloaded then go to the "Configuration" screen, and find "HTTP Proxy" and ensure that your internet connection is okay
 
AndroidStudio9.jpg
 
The next screen, after successful configuration, will look like this:
 
AndroidStudio10.jpg
 
Here, you will see that, our "MainActivity" resides in "src/main/java/com.<package>/". You can also see our resources structure. The layout file that we defined in "wizard" is here in the "src/main/res/layout" directory.
 
When I open this layout file, the following screen will open. I have made some changes to the layout file.
 
AndroidStudio11.jpg
   
When you go to the "text view" of layout, you are able to view the changes you are making in the text file, and the output will immediately be reflected in your design.
 
AndroidStudio12.jpg
 
This Android Studio has one good facility called "Preview all screen sizes", that allows the user to see the output of the current layout file with all the supported devices with simulated output.
 
AndroidStudio13.jpg
 
You are almost done with everything. Now, as you code in Eclipse, do the same here. Run your project by selecting an AVD or a real device.
 
There are so many features in this IDE, we will explore in my next article.
 

Summary

 
In this article, we learn how to create a new project using Android Studio's Project wizard with different parameters. We learned the new features of layout and project structure.


Similar Articles