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.
You will see there are 6 tabs there.
- New Project
Creates a new project with Android parameters.
- Import Project
Imports Android projects from the same or another workspace.
- Open Project
Open projects from a directory.
- Check out from Version Control
If your Android Studio was configured with Sub-version then you can check-out with it.
- Configure
Here you can do plug-ins settings, import-export settings and many more.
- 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.
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.
- Application Name
The application name is shown in the Play Store, as well as in the Manage Application list in settings.
- Module Name
The module name is only used by the Android Studio IDE. Generally, the module name is the same as the application name.
- 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).
- Project location
Select the workspace where you want to put this project.
- Minimum SDK version
Choose the lowest version of the Android SDK that is supported by your application.
- 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.
- Compile with
Choose the API to compile your Target SDK.
- Theme
Select the Base theme of your application.
- Create Custom Launcher Icon
If you would like to define a custom launcher icon in this wizard, select this option.
- Create an Activity
If you would like to create an activity from the default selection then check this option.
- 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.
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.
You can also select "custom image" from Clipart.
You can also select the option "Text" to set the launcher text icon as in the following:
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.
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.
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
The next screen, after successful configuration, will look like this:
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.
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.
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.
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.