Introduction
Hello everyone again, in this article I am going to cover the basic setup for android using Eclipse and Android Studio. During the discussion, i am going to cover the points given below.
- Comparison of the new Android Studio vs. Eclipse IDEs.
- Step-by-step guide on setting up a basic development environment for Eclipse and Android Studio.
- First Android Virtual Device (emulator).
- Other tips and best practices.
Before start discussion, I want to say one thing, Eclipse IDE is Wow, I am very impressed from eclipse IDE, since I worked with Android, PhoneGap, Java and J2EE projects. This is my point of view :D Please don't mind it
Comparison of the new Android Studio vs. Eclipse IDEs
Let me compare one by one both the IDEs.
- Setup
- Android studio is dedicatedly developed for android development, So that most of important things are configurable. Like no need to configure the android sdk and so on.
- Eclipse is a blank ide for you, you have to download everything like sdk and avd manager and configure it for your Development.
2. Source Safe and TDD
- Android Studio comes within build source safe tools and builds automation tools gradle.
- In Eclipse again you have to configure for the source safe tools and there is no Inbuilt support for automation tool, Again you have download it and configure it.
- In Both the IDEs you can create a test driven project for TDD
3. Creating New Project
- In Android studio, launch screen is always asking you to create a project or add already existing project.
- In Eclipse you have to choose it from project menu, As it is not a dedicated IDE for android, so it will ask for another project too like J2ee or core java projects.
- Once you select new project in Android studio, It will follow the same steps that Eclipse will follow, Only the difference is Android Studio will download the latest sdk Select by you and give you more templates for view. While in Eclipse you have less choice.
4. Customize you view
- In Android Studio once you select your layout screen you can easily modify your view component, same we can do it in Eclipse. Only the difference I feel about layout window look like a big device in Android studio.
5. Look n Feel
- Yes I can say the Android studio is more user friendly to run your project inbuilt AVD customization option makes it more user friendly. Also you can develop your view for android TV or bigger screens. New Palete bar provide much more in build options like if you want to add a language, yes you do it easily.
- While in eclipse you have to configure the AVD before it use. Palete bar is not much more advance like Android Studio has.
6. Build, Run and Debug Options
- In Android Studio header you can easily find out tools for run you application, And it have in build support of Gradle.You can easily debug you application too. Most of the features are inbuilt while in Eclipse you have to configure it.
7. Configure Real Device and Emulator
- Emulators are very slow in Android. But you can easily connect your android device with Eclipse and Android Studio, Not even connect you can also debug your application directly from device too.
8. Performance
- While During the development I feel that Android studio is faster than Eclipse.
Step-by-step guide on setting up a basic development environment for Eclipse and Android Studio
I want to Start with Eclipse for Windows :
- You have to download the Eclipse. Click here for download .
- Make sure that Java is installed Other wise click here for download the JDK package.
- Eclipse setup comes in a zip file. Download it and Extract it in your preferred location.
- Open the Eclipse click on help menu and select install new software.It will open an another window as shown in figure given below.
Click on Add button it will open a new popup window again.
Give any name you want and in location textbox paste the url 'https://dl-ssl.google.com/android/eclipse/' and click on ok button.
5. Once you will click ok then it will return to the first window with list of android plug-in given below.
Select the plug-in you want to install and click on next button. It will check the dependency the fetch the packages according to it. Please make sure that you internet connection is working properly.
6. Download the SDK Manager first, Click here to download it. Or you can also download the complete package of Android with eclipse from here.
7. Once you have downloaded the sdk manager. Double click on it and run the set up. Once your setup has been completed..
It will open a new window like given below.
Select the API and tools install it on you machine.
7. Now configure your eclipse for android SDK. Open your eclipse and click on the window tab then select preferences it will open a new window given in below screen shot.
Click on android and Browse the sdk location it will fetch the list of API installed on your system. Select your default API and click on ok and Restart your eclipse..
8. Configure the AVD manger. Select Window > Android Virtual Device Manager, or click the AVD Manager icon in the toolbar and configure it or you can configure it directly Navigate to your SDK's tools directory and execute android AVD
9. Once you will configure it Add new project.
Click on project it will open the new window
Select an android application project for new project and click on next button
Give the application name,project name and package name. Also select minimum version and maximum version of SDK and click on next.
Click on next
Select the launcher icon n rest of the setting and click on next button
Select the Activity you want and click on next button.
Configure the layout and activity name here and click on finish button. it will create a project for your in project explorer window.
Let me explain the directory structure in short .
src -> package -> java class or activity file gen-> package -> r.java and buildconfig.java
bin -> apk file libs-> libraries res-> UI files and folder
AndroidManifest.xml is configuration file for this project.
To run this application follow the figure given below:
Configure your application first Click on Run -> Run Configurations.. It will open a new window
Configure your project here and set target device which is used to deploy your application.
As I have discussed about the steps for eclipse very long process right. But Android studio you download and install and create new project in 5-6 steps.
Steps up For Android Studio for window
- Download the Android Studio . Click here for Download it.
- It will download the zip package named as "android-studio-ide-135.1248636-windows.zip".
- Extract the Zip Package on your preferred location. Select extract location >> android-studio >> bin >> studio it will open the Android Studio for you.
- first screen of Android Studio
- For first time it will ask for some configuration , and it installed No need to do any kind of configuration and all ;).
- Now create a new project from file menu and configure your project application name package name and all. I am going to attach my configuration window in form of image given below. Click on next button.
- Now you have to configure sdk version for your app. I am going to attach my configuration window in form of image given below. Click on next button.
- Next window will ask for an activity. I am going to select a blank activity template. Android studio has more templates. Click on next button again.
- Next window will ask for activity name, layout name and title, fill it and click on finish button.
- After that it will load your project in android studio.
- Finally, I am going to show my window.
- Next step to run your in emulator. You have to configure your emulator first, and then only you can run it and see the outcomes.
First Android Virtual Device (emulator)
I am going to show the screen shot for both the IDE.
Other tips and best practices
- We can also configure our eclipse for hybrid app environment like PhoneGap , In which you can develop your app using a html5,CSS3, Jquery Mobile .PhoneGap says develop once and build it for other device too. To know more about it clicks here.
- You can also configure your android phone to deploy your app directly on phone. You can also debug your application from your android device. Connect your device to your pc or laptop, after that whenever you will run your application, it will always ask to choose your device for deployment. Please follow the settings of your android device is given below
Click on Phone Settings -> Developer options -> check USB debugging.
- If you are going to use an emulator make sure your emulator initialization should be done. Start it 5 mins before it using.
- Always use string.xml for constants.
- Use Proper and Clean coding approach and always choose a proper package names for your app.
- During the demo ,I feel like Android studio is much faster than Eclipse, But the problem i have figured out whenever you are going to create a new project it will open a new IDE window for you, But in eclipse it will add the new project in same Project explorer.
- Last thing I want to say Happy Coding :).
Points of Interest
I am trying to cover every things to setup your android development enviornment for both the IDEs. I hope so this post will be helpful for beginners. You can also follow my next article in which i have created a sample application and explain the folder structure of android project , click here to know more about it.