Learn Basics of Android Studio
This article is to give a brief description about a new Android Development IDE.
In this article I have tried to address basic questions about the new Android development IDE, Android Studio.
What is Android Studio?
Android Studio is a new Android development environment launched by Google to make the Android programming much easier. This IDE is based on IntelliJ IDEA.
What does Android Studio offer?
- A deep set of analytical tools that will help you develop your code and analyze it before shipping.
- Provides more meta information about which routines could send back a null pointer.
- Provides a drag-and-drop set of tools for designing your Android layouts. You can drag around the widgets and the Studio will modify the XML underneath.
- When you work on Android Studio, it gives a "Tip Of the Day" every day. This helps you become familiar with the new IDE. For example: the tip I got today was that "Ctrl+Q" is to be pressed to get the documentation of any element that you use.
- Lets you pop-up the design in various sizes and various devices. This is a wonderful innovation for Android developers who must design their apps to fit a large number of various screens.
- Gradle-based build support. This provides flexibility, customized build flavors, dependency resolution, and much more.
- Android-specific refactoring and quick fixes.
- Template-based wizards to create common Android designs and components.
- Includes a powerful code editor. It's based on the IntelliJ IDEA editor, that supports features such as smart editing, advanced code refactoring, and deep static code analysis.
- Easy access to Google services with Android tools. A new plugin called ADT Translation Manager Plugin has been added to assist with localizing your apps.
What is IntelliJ?
IntelliJ is a commercial IDE complete with various features. It consists of a complete set of tools and integration and some most important modern technologies and frameworks such as Spring and Hibernate, necessary for effective Web and Java EE development.
Android Studio and IntelliJ:
- Android Studio and the Android plugin for IntelliJ IDEA are built from the same code, and all of the changes in Android Studio are, and will continue to be, available in IntelliJ IDEA releases.
- New features of Android Studio are not available for older versions of IntelliJ.
- Android Studio is focused specifically on Android development and provides streamlined environment and project setup, but otherwise all of its features are available in IntelliJ IDEA.
- Android Studio and IntelliJ projects are compatible with each other.
What is Gradle?
- It is a project automation tool that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy based DSL instead of the more traditional XML form of declaring the project configuration.
- It is an advanced build system as well as an advanced build toolkit allowing creation of custom build logic through plugins.
- It provides Domain Specific Language (DSL) to describe and manipulate the build logic.
- It provides good API tools allowing IDE integration.
- It is very flexible and allows use of best practices but doesn't force its own way of doing things.
Why is Android Studio better than Eclipse?
- Developers encountered many problems with Eclipse, like when Eclipse upgrades, it produces incompatibilities itself with the Android tools.
- The layouts are not that good in Eclipse
- You can have the preview of the layout you are designing continuously in Android Studio. You can launch your app in various sizes and for various devices at the same time. These features are not available in Eclipse.
- IntelliJ is far better than Eclipse.
- When adding color codes, you can view the color on the left of that statement in Android Studio but not in Eclipse. This helps in designing.
There is a lot of confusion of whether Eclipse is better or Android Studio. Well for me Android Studio is better since it provides so many more functionalities, is much more interesting and fascinating than Eclipse. However I have seen some developers supporting Eclipse since they are quite comfortable with Eclipse since they have been working with Eclipse for 6-10 years. But I believe in moving forward with technology. You can encounter problems when you start using something new, out of your comfort zone, but then that is what is challenging and interesting. Besides, Android Studio provides many more tools and functions.
Are There Problems with Android Studio?
- The debug cycle pauses when you're waiting for the Android Virtual Device to start up.
- Not only are some of the buttons in various places, but Android Studio is heavily integrated with Gradle, the latest build tool. If you're still stuck on Ant or Maven then you'll need to adjust to yet another innovative solution for building your software where everything is slightly different. From the arrangement of the files to the languages, everything has morphed a bit.
- It is not yet ready. It is still in development. It has great support for things like Maven or Gradle, it's faster, it's smart (code completion, refactoring, etcetera).
The basic components of a project made in Android Studio
Your project name->src->main->java. Then inside a package you will find MainActivity.java that just sets the content view to the main activity layout fie
For creating more Java classes just right on the package->New->Java Class. Then name this Java file created.
XML layouts files
These files help you design your app. Like adding buttons, text fields etcetera.
Your project name->src->main->res->layout. You will find the default "activity_layout.xml" here that just defines a TextView displaying "Hello world!"
All the external files to be used are to be placed here like any jpeg image, .mp3 file etcetera.
Your project name->src->main->res->drawable. Initially it contains "ic_launcher.png". You can add other resources by simply copying the resources on the clipboard and then pasting them in drawables.
You will find many drawable folders, in other words drawable-hdpi, drawable-xhdpi etcetera. These are for having a display in various sizes and on various devices.
Used for formatting.
Your project name->src->main->res->values. This consists of "dimens.xml", "strings.xml", style.xml" by default.
"strings.xml" defines the various texts that will be used in your code. It is always recommended to use this file instead of writing the text then and there.
"dimens.xml" defines the various sizes that can be used in you code. This can help in resizing the various elements.
You can add other resources also. "colors.xml" is a resource that will be used very frequently in your code, to make your layouts attractive. You can define the various color codes in this file.
This file defines the names of the "activities" used in your code. If you forget to add the names of the newly created "activity" classes here, then you will not be able to view them while running your code.
Your project name->src->main->AndroidManifest.
Running+Debugging your code:
Debugging your code:
Your project will run on the Emulator you chose.
AVD (Android Device) Manager->New. Fill in the details like AVD name, Device (Nexus 4, Nexus 10) etcetera.
Click here to download the Android Studio.
I hope this article has cleared some of your doubts about the new IDE. Please feel free to add something new to this discussion.