Developing Your First Android Application with IntelliJ IDEA on Ubuntu

Developing Your First Android Application with IntelliJ IDEA on Ubuntu
Developing Your First Android Application with IntelliJ IDEA on Ubuntu
If you are a programmer or have just started learning programming and you are loving the Smart-phone technology, then you would definitely love Android Programming as Android is the Future of Mobile Technology. If you know Java than things will be lot easier to learn. Although people with knowledge of other Programming languages can also learn it easily. You just need to enjoy it, because Programming is Fun and to create something makes us feel great, no matter what it is and Android makes it more beautiful.

So lets start with developing a basic android application with IntelliJ IDEA  which is an official Android IDE. Most of the tutorials on Internet are about using the Eclipse IDE, but IDEA is better in terms of performance as Eclipse really slows down the system. But an IDE should not be a constraint for you for developing the application. So if you enjoy working on Eclipse, you keep going with it. But try to work on IDEA also, you can feel the difference.

Let start with developing our first application on Ubuntu, but before that we need to set up the environment for application development. Two basic platforms required for starting Android Application Development are:

1. Java SDK:       You can get it Here
2. Android SDK: You can get it Here

Follow the required installation instructions to get the system ready for Android Development. You can skip the Eclipse ADT plug-in part as we are Using a Different IDE. Once you are done with the Required platform setup, you need to install the IntelliJ IDEA IDE which you can get it Here. Since we are working on Ubuntu, you need to get the Linux version of the IDE. Download and Extract the requited gz file and then inside the bin folder, run the idea.sh file to start the application. You should see the page like this:

Click on Create New Project and the following should be displayed.


Click Next and you should see below Screen. Enter the Project Name as shown
 and Select Module Type as Android.

  

Click Next and you should see below screen and by default create Source directory radio button should be selected. Leave it as it is. You src directory will contain files related to the application source.


Click Next and you should see below screen or before that you could one more screen where the application will ask for JAVA SDK path. Select that path and after that you have to select path for the Android SDK path which you can see in the top in below screenshot.


You should be prompted to select the SDK path as shown below:


Also in the previous screen-shot you can see the option for selecting the Target device where you will run your application.  We will be using the Emulator to run our application. So we will create a Virtual Device to run the application. A Virtual device is same as Physical device and it will show us the behavior of the application on the physical device. Select Emulator and click on Prefer virtual Device selection box to create the Virtual Device. You should see screen like below:


Give your virtual device a name and target platform for which you are simulating the behavior. After adding the details Click Create AVD and then you can choose the created Virtual Device in the Emulator option and then click Finish. You just created your first Android Project. :). 

Under Project Explorer, you can see the Project just created. And Click under src directory, you could see that the package created has the activity file created automatically, which is the main file for your application. 


Click the Green arrow button on the top to run your application. The IDE will launch the virtual Device and will run your application and the output should look like below.



Your first Android Application is ready!!









Kill Android SDK Manager Process in Linux

Android SDK Manager is required to download the tools for the Android Application development. And its been observe that it gets hanged and even if you try to close it from GUI , you won't be able to close it. Doing the CTRL+ALT+DEL can come to the rescue but in virtual machine its not the solution. The best way for such situations is to kill the process.


And you just need to type:  kill <process id>
To know the 'Process Id', we need to know the processes which are currently running and for that we type:
                                                   ps -e

To see more details of the processes, we can use another command:
                                   ps -aux | more
Now we need to know the process id of the android sdk manager and to know that, you need to type:
                               ps -aux | grep 'android'
And it will give you the complete output which would look something like this:
pc 2424 0.4 2.6 469844 54700 ? Sl Jun16 2:52 java -Xmx256M - Dcom.android.sdkmanager.toolsdir=/home/pc/Documents/android-sdk-linux/tools -cla sspath /home/pc/Documents/android-sdk-linux/tools/lib/sdkmanager.jar:/home/pc/Do cuments/android-sdk-linux/tools/lib/swtmenubar.jar:/home/pc/Documents/android-sd k-linux/tools/lib/x86/swt.jar com.android.sdkmanager.Main root 3290 0.0 0.0 0 0 ? S 09:41 0:01 [kworker/0:3]
So here you can see the process id which is: 2424.
Note: If you try to find the process is using:
                                        ps -e | grep 'android'
You won't be able to see the output because the ps -e command doesn't have the full name.But to find the process with this command you need to type:
                                   ps -e | grep 'java'
It will give the same process id which is same as the process id returned by running the command: ps -aux | grep 'android'. So just verify the id for both processes for confirmation and go ahead..


Now, to kill the process, type in Terminal:
                                     kill 2424
If it doesn't kill the process as it might be used somewhere or by another resource, we need to kill it forcefully. So in that case we type:
                                   kill -9 2424
And we are good to go. Please change the process id as it will be different for your case. And Bingo, the process is gone. You can do the same for other processes also which are bothering you and are not going away.
Hope it helps.