Click here to Skip to main content
15,867,835 members
Articles / Programming Languages / Java

Android Dev Environment for mutiple OS

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
3 Aug 2014CPOL11 min read 16.1K   5   4
Article #2 for the challenge

Introduction

This article will provide a walkthrough on setting up different Android Development environments of different Operating Systems. It will enable beginners to get a grip on how different environment are in different Operating Systems yet producing the same output as a result.

Background

I have made this article for different versions of  android development environment  setups in multiple VM images. This article will help you setup Android environment in Linux,MAC OS and Windows. As I had little knowledge about MAC OS I will also show the steps I took while setting up the environment as well as common errors faced creating the Android Developpment environment.

Comparison between Android Studio and Eclipse Android SDK

This is a detailed comparison of Android Studio and Eclipse

Android Studio

Android Studio is a new Android development platform developed by Google keeping future in mind. It's in Beta phase

Eclipse

Eclipse is the mother of all IDEs and it is well known development platform for android development. Google have developed the Android plugin for eclipse which is used predominantly.

Platform

References http://www.jetbrains.com/idea/

Android studio is based on IntelliJ IDEA which offers features and sets based on most modern technologies and frameworks for enterprise and web development.

Eclipse is based on Apache-ant which is one of the oldest software tool meant for Java development

Build System

For Android Studio it is Gradle

Gradle is build automation system evolved.Gradle combines the power and flexibilty of ANT with dependency management and conventions of MAVEN into a more effective way of build.

For Eclipse ADT the build system is ANT

Both Supports graphical layout

NDK support coming soon for Android Studio but it's there in Eclipse ADT

It means it is impossible to code in native languages such as C++ in Android Studio

Is there an alternate way?

here is the catch the issue is also resolved as per the latest finding as is well explained in IDZ video we can also code now in native language, there is an entire video showcasing how it can be done

  1. https://software.intel.com/en-us/videos/using-the-ndk-with-android-studio
  2. http://kvurd.github.io/blog/compiling-a-cpp-library-for-android-with-android-studio/

What's more as Android Studio is still in Beta phase there will be lot of updates until it gains its full functionality whereas Android Eclipse SDK is already a fully developed IDE so it is more stable as of now.Google have decided to make Android Studio to be the best IDE with all available frameworks for Android.

Creating an Android Development environment for MAC OS

You need to download Java for the Mac OS

Where to get it?

first of all check that you have java installed on your machine or not

Go to the terminal

Image 1

As you launch the terminal check that if you have any java version installed using this command in the terminal

java -version

and then hit enter, if it is present it will show the version or if not present it ask for new installation

Image 2

Click on More Info and it will take you to download link

When the download is complete,open up the downloaded dmg file via finder and then double click on it to get the installation started.The package on a new window will open up, double click the pkg file to complete installation.

Image 3

after the installation is complete recheck on terminal window, the version of Java

java -version and then hit  enter

it will show you the current installed version.

Installation of Android Studio

In google search type in Android Studio and it will take you to the download page, download the MAC version of Android Studio.

Image 4

when the dmg file is downloaded. open it in finder

Image 5

Double click on it for installation.

Image 6

click on I don't have a previous version of Android Studio and hit ok.

Image 7

After the setup is complete you will see that the android studio have started.

Image 8

Click on Configure to see that the android SDK manager is available or not at my end it was greyed out, so I had figure out an alternate way and then thought of installing the eclipse ADT for Android to get it going.

At google search type in Eclipse Android SDK and the download link will appear.Start the download.After downloading is completed open the file in finder.

Image 9

Now as my SDK Manager was greyed out I had to show the path of Android SDK to my Android Studio IDE. I Opened Android Studio clicked on configure clicked again on project defaults and then went to project structure and included the Android SDK path

Image 10

Afre that I click on OK closed Android Studio restarted the Android Studio and saw my SDK Manager and was good to start with.As I am using VM I updated a lower version of android update(2.3.3) to get the AVD up and running

Image 11

Then start installing the packages and accept the license.

Image 12

and after that you will be up and running with Android SDK and Android Studio setup.

Creating an AVD in Android Studio

As I pulled up the SDK Manager in there at top i didn't find any tools AVD Manager options so I went other way round by creating a project and then creating the AVD.

Image 13

Image 14

Accept the default and then click next

Image 15

required SDK  to API 10 and then click next again

Image 16

Check blank activity and click next.

As the project opens up click on AVD Manager

Image 17

After that click on create

Image 18

Put in AVD name, check the Device image you want to build the image for,target as API level 10 and select the skin and then click on ok.

Image 19

Select the AVD and then Start it.

Image 20

click on launch

Image 21

The AVD will start.

Image 22

Image 23

Yahoo!! the AVD is up and running in Android Studio

Creating an AVD in Android Eclipse SDK

Open Eclipse from the folder and double click on the android eclipse icon

Image 24

and it will ask you for workspace accept defaults

Image 25

Create a new project

Accepted the api levels I made it 10 as I was using a VM

Image 26

Then click on create an AVD icon to start the process

Image 27

AVD creation done

Follow the same steps followed and you are up with the avd.

Image 28

You are up and running with AVDs ..

Important Part setting JAVA_HOME

Issues that you could face while logging and working on terminal

Bash profile creation

Bash_profile is essential for working on command line in MAC OS.A normal install might not create a batch profile for you.I have had faced this issue and you will get something like this you need to checkthat you have Bash_profile or not.Put the following command on terminal to check it

open -a TextEdit ~/.bash_profile and hit enter if it is present it will show otherwise you will get this error.

 

Image 29

In this case you will have to create a Bash_profile

the commands you need to put in terminal to create the Bash_profile

touch ~/.bash_profile and the hit enter

 

another command you need to put in the terminal

open -e ~/.bash_profile and then hit enter

 

It will open a bash_profile Window as shown below

Image 30

In the bash_profile window  you need to write these details line by line and then save it.

export JAVA_HOME=$ (/usr/libexec/java_home)

export JDK_HOME=$ (/usr/libexec/java_home)

Hit Command + s to save and then close it.

On the terminal window put this command

source ~/.bash_profile and hit enter it will load the environment.

Creating an Android development environment in Linux

Installation of Java

open a terminal in Linux

type in the command java -version and then hit enter.

It will show which version is there.

Check for the updates using the command

sudo yum install java and then enter

After that I faced an weird issue which can occur to any user the problem was user is not in the

sudoers file.The incidence would be reported.

Image 31

We had to add the user to Sudo profile.

Had to try different ways

Image 32

Getting to the vi editor and appended the file mohit ALL=(ALL)ALL

and I was good to go.

here mohit is the username

my issue was resolved.

Starting the Java installation

Get in to the JAVA Oracle website or type in Java install in Google to get the download link Download i586 32 bit rpm

Image 33

Accept the terms and start downloading Save the file

Image 34

Right click on downloads and open the containing folder

Image 35

Now on the permissions tab you need to select the checkbox that says allow executing file as a program

Image 36

Double click on the JDK version folder it will ask for install

Image 37

In general installation starts but in my case I had this conflict error

Local file conflict between packages:-Two packages provide the sam file.This is usually due to mixing packages from different sources

Image 38

so went back and uninstalled the conflicting version as I already had JRE by default

I used this command

rpm -e --noscripts jre-1.7.0_17-fcs.i586

and then hit enter and it removed the older version of JRE that was present.

Image 39

and after a restart I was able to install java and it went through without errors.

type in Android Studio in google and it will show you the download link

Image 40

It will ask for accepting the license just click on it.

Image 41

As you click on it will shows the file to save

Image 42

As the download completes you need to extract the file so extract the file to tmp

Image 43

extract to temp

Image 44

extraction starts

Image 45

Now go to the file system

Image 46

go to the tmp folder where the android studio was extracted.

Image 47

get into the bin folder

Image 48

right click on studio.h file and open it

Image 49

then click on run in terminal

Image 50

then for the time importing your settings you need to click on previous version of Android Studio and click ok

Image 51

Then you will get the main interface for Andoid-Studio

Image 52

We need to click on SDK Manager

Image 53

Click on tools

Image 54

Click on Manage AVDs

Image 55

Then click on create

Image 56

updating the android api version I am putting it lower one as i will be creating the AVD in VM.

Image 57

Accept the license and then click on Tools and then Manage AVDs and then click on create a new one

put in the details for creating the AVD

Image 58

When the AVD is created click on ok

Image 59

After creation of AVD click on Start

Image 60

And you are good to go.

Image 61

Creating an Android dev environment on Windows OS

Installing Java

In google search engine you need to type in Java download

download it from the oracle.com website Java link

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Double clicking the installation file starts installing the Java files

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

download the windows x86 package

Image 62

After installing we need to configure the environment specifically create JAVA_HOME

Right click  on My Computer(this pc) and then go to the properties option

Image 63

Click on advanced system settings

Image 64

Then go to environment variables

Image 65

Set the path for JAVA_HOME give the entire path till bin

Image 66

Installing Android Studio

At Google search type in Android Studio and it will take it to the download link

https://developer.android.com/sdk/installing/studio.html

Image 67

Accept the license and start installation

Image 68

Click on next as per the process installation happens and the IDE is installed.

After installation click on new project

Image 69

and then click on configure

Image 70

then click on sdk manager

Image 71

update the android SDK Manager with API level 10(2.3.3)

Image 72

Click on tools and then click on manage AVDS

Image 73

Click on create and then setup your AVD names etc

Image 74

hit ok and then select the AVD and then click on start and hit launch

Image 75

The AVD will be up and running

Image 76

Creating an AVD in Eclipse

At google search we need to type in android sdk it will take you to the download page

http://developer.android.com/sdk/index.html

Accept the license terms and download the 32 bit version of Android ADT go to the folder where it is downloaded

Image 77

Double click on SDK Manager and then update the API version needed to create the AVD and then click on tools and then manage AVDs same as before create a new one

Image 78

AVD will be up and running

Image 79

After all  our efforts we managed to create AVDs in three different OS(MAC,Linux and Windows) and it has helped us know more about how we go about creating the development environment in different Operatin Systems .We came across certain issues which were unknown and resolved it.

Tips and Best practices

Try to test as much as possible before taking the app live to store.Make sure you go through all the steps mentioned on creating the development environments as each platform has its own issues and ways of resolving them.Try developing more native apps in Android Studio. If you want your emulator to run faster try using geny motion(it is a third party emulator which is much faster than default emulator which that is present in Android studio).Download link :-https://cloud.genymotion.com/page/doc/#collapse4

If you want to accelerate the VM using native Android Studio you will require Intel HAXM package.

Intel has come up with new IDE which has all the capacities built together in a common platform where in you can bind different things together to the interface

Image 80

It comprises of latest C++ compiler and different modules such as Threading,Media etc.

You can also customize the setup for different platforms as shown below

Image 81

References

Points of Interest

It's been a great time setting up developer environment for different platforms as I came know how I would go about installing Android SDK on different platforms and what are th common issues one would face.

History

The first version of the article is ready

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
I am into software Development for less than a year and i have participated in 2 contests here at Codeproject:-Intel App Innovation Contest 2012 and Windows Azure Developer Challenge and been finalist at App Innovation contest App Submission award winner as well won two spot prizes for Azure Developer Challenge.I am also a finalist at Intel Perceptual Challenge Stage 2 with 6 entries nominated.I also won 2nd prize for Ultrabook article contest from CodeProject
Link:-
http://www.codeproject.com/Articles/523105/Ultrabook-Development-My-Way

Microsoft MVA Fast Track Challenge Global Winner.
Ocutag App Challenge 2013 Finalist.

My work at Intel AppUp Store:-

UltraSensors:-
http://www.appup.com/app-details/ultrasensors
UltraKnowHow:-
http://www.appup.com/app-details/ultraknowhow

Comments and Discussions

 
GeneralMy vote of 5 Pin
Ranjan.D5-Aug-14 11:31
professionalRanjan.D5-Aug-14 11:31 
GeneralRe: My vote of 5 Pin
Abhishek Nandy5-Aug-14 23:00
professionalAbhishek Nandy5-Aug-14 23:00 
GeneralThanks for entering! Pin
Kevin Priddle5-Aug-14 7:26
professionalKevin Priddle5-Aug-14 7:26 
GeneralRe: Thanks for entering! Pin
Abhishek Nandy5-Aug-14 8:55
professionalAbhishek Nandy5-Aug-14 8:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.