Mobile App Development Tutorial Using Android Studio
Android Studio is now the only official development tool that will support the full-featured Android SDKs in the future. If you are like myself, skeptical about the beta release or reluctant to get away from the popular IDE in Eclipse for the past several years, the wait is over. This is about the right time to move towards Android Studio if you would like to continue to enjoy new upcoming Android features offered by Google. The reason is simple: Google will no longer provide updates for the Eclipse plug-in or ADT (Android Development Toolkit) and will only release new SDKs for its own Android Studio.
In this article, we will briefly cover some key topics, such as where to get the download, how different it is from Eclipse, how to import/export/create projects, basic signing tools, and some useful shortcuts to make your development time easier.
Installation and Feature Overview
The Android Studio download package, available at https://developer.android.com/sdk/index.html, contains everything required for your app development and more, including the IDE itself, SDKs, Wearable Platform, Cloud Platform, Google Services, and so forth. The Installation wizard will guide you through step by step, so the process should be a breeze. There are numerous neat features offered by Android Studio. I'll just comment on some of them from my own development's perspective:
- Gradle: This is probably the most noticeable difference for avid Eclipse users. It is a very flexible build system that can create multiple targets for your app with various features by the same project and modules. It also can customize and configure the build process.See the project view in Figure 1.
- Cloud integration: You can use the Google App Engine to connect to the Google cloud with minimal effort.
- lint: It identifies performance, compatibility, and other problems.
- Dynamic layout view: The layout editor allows you to drag and drop user interface controls into your layout and preview it while editing the XML.
Figure 1: Project View
Android Studio vs. Eclipse with ADT
Many developers have been using Eclipse with ADT for their main app development, so it should be beneficial to know what the key differences are while migrating to Android Studio. First off, many external tools often used are under "Tools->Android->" as in Figure 2, including "SDK Manager" to get the latest SDKs and "AVD Manager" to configure your virtual devices.
Figure 2: External Tools
The one major difference between Android Studio and Eclipse is the gradle build system offered, as you can see in Figure 1. These new build files are in plain text. They are confined to syntactic rules and used to configure the build with the elements. Very often, when you actually need to hand-edit these files, you only work on them at the module level. Even more often, you don't even need to touch these files at all, but it doesn't hurt to browse through them occasionally for a better understanding of what modules could be involved.
Android Studio embeds a powerful layout editor for you to drag and drop controls into your view and preview on many different devices at the same time. See Figure 3.
Figure 3: Layout Editor
Integrating Google Cloud into your app is as simple as doing it through "File->New Module…->Google Cloud Module", as in Figure 4.
Figure 4: Google Cloud
Importing, Creating, and Exporting Projects
To import the existing Android projects not created by Android Studio previously is pretty straightforward; simply select "Import Non-Android Studio project" from the "Welcome to Android Studio" dialog, as shown in Figure 5. Basically, the process will generate the gradle build files and organize all the files with the specific folder structure.
Figure 5: Import
Exporting a project from Android Studio to something Eclipse-compatible is a cumbersome task for now because it requires some manual processing work. Moving forward, new projects should be all compatible with Android Studio, so exporting a utility becomes not as necessary. For those who really want the conversion done, please find the info in the references.
Creating a new project is simply as easy as selecting "Start a new Android Studio project" from the "Welcome to Android Studio" dialog and you will come to the page similar to Figure 6. As you can imagine, there are some occasions when you want your app to run on multiple devices (for example, wearable and mobile modules), so you will be asked to specify their respective SDKs and options. Their templates and gradle build files will be generated and managed through the project settings.
Figure 6: New Project
App Signing Before Publishing
Before you can publish your app for public consumption, you need to sign it with your own certificate; in other words, key store that uniquely identifies you as the author. Assume you already know how to create a free key store. Android Studio offers you the choice to sign a specific app apk file every time manually as well as insert the app signing into the build process. I would recommend you at least set up the automatic signing for the release build type. The manual app signing is through "Build->Generate Signed APK…". The automatic process is set up through right-clicking on the app and selecting "Open Module Settings". Use the "Signing" tab to configure the key store; for example, "signing1" in our example illustrated in Figure 7. And then switch to the "Build Types" tab and select the configuration we just created, as in Figure 8.
Figure 7: Auto App Signing Configuration
Figure 8: Auto App Signing Selection
Conclusion
This is a short introduction to the official IDE in Android Studio. It is the only IDE that will receive future Android SDK updates for now, so migrating to this tool becomes a must-do. As developers, we all have our own favorite shortcuts to speed up some development effort. Here are some from my list:
- Ctrl-Alt-L: Reformatting the codes for files or selected text
- File->Settings->Editor->Auto Import: Auto-importing the class packages by enabling "Insert imports on paste All", "Optimize imports on the fly", and "Add unambiguous imports on the fly", as in Figure 9.
- Alt-Enter: Fixing common project errors automatically or making suggestions
- Ctrl-G: Going directly to the line
- Ctrl-Shift-N: Finding symbols by name
For more advanced developers using NDK, you will also need to configure gradle build files specifically for that purpose.
Figure 9: Auto Import
References
- Android Developers at: http://www.android.com/developers/
- Android Devlopment Center at: http://www.developer.com/ws/android
- Androidlet at http://www.androidlet.com
- Importing from Android Studio into Eclipse
About the Author
Chunyen Liu has been a software professional in Taiwan and the United States. He is a published author of 30+ articles and 100+ tiny apps, software patentee, technical reviewer, and programming contest winner by ACM/IBM/SUN. He holds advanced Computer Science degrees and trained in 20+ graduate-level courses. On the non-technical side, he is a certified coach, certified umpire, and rated player of USA Table Tennis, having won categorized events at State Championships and US Open.
Mobile App Development Tutorial Using Android Studio
Source: https://www.developer.com/mobile/android/android-studio-create-projects/
0 Response to "Mobile App Development Tutorial Using Android Studio"
Post a Comment