Navigation

Monday, June 30, 2014

Creating an Android Project

I assume that by now you would have installed your preferred way of development environment. I have a way with eclipse and hence would be using the same for further development. It is usually convenient to work on some editor that we are accustomed to. Now, that being said, I have also installed Android Studio to explore it. There is no harm in doing the same.

Now, lets get to the main point of discussion today - Project Creation. As with all other applications, we will want ourselves to build the very first "Hello World" Application. 
At present there are three ways of project creation that we will talk about.
  1. Using SDK
  2. Using ADT
  3. Using Studio 
Creation of a project using the SDK can include a bit more verbosity than the other ways. I would only recommend the same if you need more control on build or project creation than what an editor provides. For example, only if you have build scripts etc. For development purpose please use either ADT or Studio. They will not only provide help for starters etc. but also, render development real quick. 
Of course, needless to mention that the above are my opinions and I leave it to the reader to have his own. I will be using Eclipse ADT more for development.

Lets start by creating a project using the three methods.

Using SDK

There are two ways of doing this. Either, you set your Android Home/tools directory to the path and run the required commands from anywhere on your computer or you navigate to the the Android Home/tools directory and run your desired commands from there itself. 
Note: if you are setting the path the please add platform-tools/ as well to the path environment.

1. You would need target Id to create Android project. To see the available targets installed run the following command.
android list targets
After you have run the same you'll see the installed targets on your computer.

Available Android targets:
----------
id: 1 or "android-19"
Name: Android 4.4.2
Type: Platform
API level: 19
Revision: 3
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : default/armeabi-v7a


If the available targets are not as desired you may need to install them using the link

2. After you have identified the targets you can create the project.
Run the following command

android create project --target 1 --name TheFirstOne --path C:/Projects/TheFirstOne --activity MainActivity --package org.ram.thefirstone

I have created the project using target 1 that I could see using the list target command in step1.
After the successful run I can see the following output

Created project directory: C:\Projects\TheFirstOne
Created directory C:\Projects\TheFirstOne\src\org\ram\thefirstone
Added file C:\Projects\TheFirstOne\src\org\ram\thefirstone\MainActivity.java
Created directory C:\Projects\TheFirstOne\res
Created directory C:\Projects\TheFirstOne\bin
Created directory C:\Projects\TheFirstOne\libs
Created directory C:\Projects\TheFirstOne\res\values
Added file C:\Projects\TheFirstOne\res\values\strings.xml
Created directory C:\Projects\TheFirstOne\res\layout
Added file C:\Projects\TheFirstOne\res\layout\main.xml
Created directory C:\Projects\TheFirstOne\res\drawable-xhdpi
Created directory C:\Projects\TheFirstOne\res\drawable-hdpi
Created directory C:\Projects\TheFirstOne\res\drawable-mdpi
Created directory C:\Projects\TheFirstOne\res\drawable-ldpi
Added file C:\Projects\TheFirstOne\AndroidManifest.xml
Added file C:\Projects\TheFirstOne\build.xml
Added file C:\Projects\TheFirstOne\proguard-project.txt

The project is now successfully created. Congratulations !!!

Project Directory

The complete project directory can be seen above. We discuss the details of the structure shortly. Thst is it. You have created your first project.


Using ADT

Creating a project using ADT is also simple. Open ADT by double clicking the eclipse.exe file in /eclipse folder of your installation.

Add a Project using ADT
1. Go to File, New, select Android Project as shown above.

Project Details
2.  Add the Application Name in the textfield provided next to the Application Name Label. Project Name and package name are auto filled.
3. Rest of the labels are quite intuitive. There is also description that is available for all the fields that are required to be fill. Still I'll explain these later on. For now, put Target SDK as the max available. 
4. After filling the fields  Click next. You'll see the below screen.


Project Details
5. Click Next. Leave all the fields as default.

Project Details
6. For the above as well, leave all the fields as default and click next.

Project Details
7. In the above screen select Blank activity and click next. We'll explain about the same shortly.

Project Details

8. Finally the last screen, keep the default names and click Finish. 

Now, your project will be created for you in ADT. If the creation is successful, the below screen will be visible.

Project Created
The above displays the complete directory structure and to the right the fragment xml is opened. 

The project is finally created and we can start development in ADT. 

Note: There are some default files created. For now, leave them as it is. The details will be covered later.

We will cover the rest in the next blog. In this we have seen how to create an Android project using command line tools and ADT. In the next section we'll create projects Studio and would also cover some of the details we skipped here. 








Friday, June 27, 2014

Install Android

Now that we are here, I can assume that we are quite convinced of app development for Android. Still there may be few uncertainties that can creep up. Well, lets not discuss about why's of Android again and lets just say we want explore this a bit further. I am sure once we look at how easy it is to setup, we can have our ways cleared.

Android development core can be called as Android SDK. This can be easily downloaded from the net from the android development page. After, you have downloaded the sdk, you may need an IDE for development ease. My favorite is eclipse. Yup, you can download a plugin that could enable your eclipse to support Android development. 

There is a a shorter way of doing the same. A pre-configured or customized eclipse version can be downloaded as well. This will give you everything you may need from basic development all in one go.

Download a complete IDE for Android development

Let's discuss the shorter part of the installation first as it will be easier and preferred.

Installing the Eclipse ADT Bundle

After we have successfully downloaded the ADT bundle, we would have got a zip file for the same.
  1. Unpack the ZIP file (named adt-bundle-<os_platform>.zip) and save it to any appropriate location.
  2. Open the adt-bundle-<os_platform>/eclipse/ directory and launch Eclipse.
  3. After the eclipse IDE is opened click on the SDK Manager link. You will have to upgrade ADT before we can start.
  4. After the SDK is opened, Install the latest from the manager. Please visit the link to know the details. 


Installing the SDK

Your download package is an executable file that starts an installer. The installer checks your machine for required tools, such as the proper Java SE Development Kit (JDK) and installs it if necessary. The installer then saves the Android SDK Tools into a default location (or you can specify the location).

  1. Double-click the executable (.exe file) to start the install.
  2. Make a note of the name and location in which it saves the SDK on your system—you will need to refer to the SDK directory later when using the SDK tools from the command line.
  3. Once the installation completes, the installer starts the Android SDK Manager.
  4. After the Manager is opened please update your sdk using the same method as explained above in step 4.

There is another option for development. The Android Studio. It is a Beta version and said to have more development features like maven etc. Once, it is released properly, it will be the official IDE for Android development. To know more about studio - click here.

Installing Android Studio

  1. Launch the downloaded EXE file, android-studio-bundle-<version>.exe.Follow the setup wizard to install Android Studio.On some Windows systems, the launcher script does not find where Java is installed. If you encounter this problem, you need to set an environment variable indicating the correct location.
  2. Select Start menu > Computer > System Properties > Advanced System Properties. Then open Advanced tab > Environment Variables and add a new system variable JAVA_HOME that points to your JDK folder, for example C:\Program Files\Java\jdk1.7.0_21.
* Please install Java before you install the Studio. For more instructions, read this.

Well, after, you have downloaded, installed and upgraded your preferred  environment, start developing. Trust me this all you need to setup. The ease of installation and getting started is amazing. Let me know if there are any issues you face on the same.



Thursday, June 26, 2014

About Android

Android is an operating system based on the Linux kernel with a user interface based on direct manipulation, designed primarily for touchscreen mobile devices such as smartphones and tablet computers. The operating system uses touch inputs that loosely correspond to real-world actions, like swiping, tapping, pinching, and reverse pinching to manipulate on-screen objects, and a virtual keyboard. Despite being primarily designed for touchscreen input, it also has been used in televisions, games consoles, digital cameras, and other electronics. - WikiPedia

In simple terms - Android Operating System was developed for smarter mobile phones and fortunately development on Android is an Open Source Technology. Being said this why do we need Android or its development. Let me try to answer in using some statistics from the net.

If we talk about smart phones, there are almost a double increase in its usage since 2010 if we compare Tablets, Desktops and Smart Phones. Although, Desktops tops this list but the increase percentage clearly displays the popularity of mobile devices. There are countless blogs that can tell you about this.
It is predicted that the smart phone usage by 2017 will be almost 50% of all mobile usage. - Click here
One in every 5 people use a smart phone in our present world. It is said that in near time 6% of the global population will own a tablet, 20% will own PCs, and 22% will own smartphones.
We can easily see the penetration a smart phone will create. There will definitely a huge increase in the purchase of smart phones. There are many other articles on the net to state my claim.

There has been an increase in number of people owning a smart phone and hence, it can easily be said that has been increase in the usage of the features a mobile phone offers. We browse net on our mobile devices. We stream youtube videos, store our financial information, do our banking activities, pay our bills, navigate and what not on a smart mobile device today. If we want to see more click here. This page clearly tells us what all we need to know about the smart phones and its market currently. 

Even if we are clear with the statistics of the smart phones and understand the popularity of the same, we still have not answered the question that we asked ourselves - "Why Android?".

To understand this lets explore the Android usage in the smart phone market today. According to Android there are more than 1 million Android devices activated daily. If we need to dig into statistics of Android share and the rest of the OS present, we can clearly state that as of today, Android runs on 43 percent of all the world’s smartphones while Apple iOS still runs on one in five smartphones. Click here for details.

Looking at the stats we can state clearly that there is ever increase rise in smart phone usage. The future will rely more on these devices than static Desktops for daily usage. Also, We can easily predict that Android is still there to be available on maximum number of mobile devices. Doesn't this clearly talks about the fact that there are to be more development concentration on Android Apps in the coming future. 

With this I think we have explained the usefulness of the Android. Keeping the brevity of the write up we can easily conclude why it makes sense to develop apps for Android OS.