Friday, August 21, 2015

One day in Android Development Setup

Exploring does not have to be geologically, it can be knowledgeably too.

  

Plan and Estimate Time Required

  • Preparation and download ; require about 30 mins
  • Installation 30mins-90mins 
    • (depends on internet download speed). Obtain Android SDK tools is time consuming. 
  • Set up Emulator 10 mins
  • Create Hello World Android Project 30 mins
    • (Blank Activity for Android 4.4 KitKat)
  • Eclipse Project 123 - Clean, Build, and Run 30 mins

What do we need?

Hardware and OS
Computer OS :  Mac OS X 10.8.5
Phone H/W : Nexus 4
Phone OS : Android 4.4.4 (KitKat)

Tools and others
IDE : Eclipse 4.3 for J2EE
Java : JRE 6 and JDK 6

Optional :
Chrome : Version 44.0.2403.155 (64-bit)

More about Eclipse version see wiki:
Eclipse 4.3 (Kepler) require Java 6 JRE/JDK.
Eclipse 4.5 (Mars) require Java 7 JRE/JDK.

Acronyms:
OS - Operating System
HW - Hardware
IDE - Integrated Development Environment
JDK - Java Development Kit
JRE - Java Runtime Environment
ADT - Android Development Tools
APK - Android Package

Mac OS X requirement for Android SDK


Preparation and Download:

What to do
 Create new Mac User
(e.g. named the user mydev; make it simple and all lowercase. 
You will type less in the future.)
Login to the new Mac User.



Open Finder.
Select Show Path Bar;
Show Status Bar;
Show Side Bar.


Optional:
Reason: not to mess up
the existing Folders,
and store new
downloads files in
designated location.

In Finder.
Select Go > Computer.

Then,
select Macintosh HD
> Users > mydev

Then,
create a new folder,
named dev.

Then,
select dev folder,
create a new folder downloads.

Result folders,
Macintosh HD
> Users > mydev > dev > downloads.

-


In Chrome,
select Preference.

Change the download location.

File android-sdk_r24.3.4-macosx.zip will be downloaded.
-


Download Android for Max OS X click me.
(about 98MB)

Choose Other Download Options.
Select the package for Mac OS X.

In case site is moved,
google "android sdk for mac os x", and follow the instruction.

If you prefer the Android Studio, do not follow this blog.


Download Eclipse IDE for Java EE Developers click me.
(about 249MB)

In case site is moved,
google "Eclipse 4.3 download", and follow the instruction.

Optional:
Eclipse 4.3 Standard IDE.



--
--

Installation

----
To install Eclipse

copy the file "eclipse-standard-kepler-R-macosx-cocoa.tar"
from dev > downloads
and paste it to dev.

Then, double click on the tar file.

A new folder "eclipse" will be created.

Then, delete the file "eclipse-standard-kepler-R-macosx-cocoa.tar"
from dev folder.


To install the Android for Mac OS X,
copy the file "android-sdk_r24.3.4-macosx.zip"
from dev > downloads
and paste it to dev.

Double click on the zip file,
a new folder "android-sdk-macosx" will be created.

Then, delete the file "android-sdk_r24.3.4-macosx.zip" from dev folder.


To setup Eclipse

Go to folder, dev > eclipse

Double click on the purple icon, named "Eclipse".

Eclipse will be loaded, and prompt for workspace location.

Use the default
or change it as
/Users/mydev/dev/workspace

Optional:
You may also change it at
Eclipse Preference >
General > Startup and Shutdown > Workspaces


Understand Android SDK subfolders

by default, there are three subfolders.

  1. add-ons : It store additional APIs for add on functionalities. The Google APIs will be here.
  2. platforms : It is now empty, we will install from Eclipse later. For example, 
    • "android-19" folder will be created to support Android 4.4 KitKat; 
    • "android-23" folder will be created to support Android 6 marshmallow.
  3. tools : It store tools for development such as ant for build, view management, and debugging...etc.
New Android SDK subfoldersnew subfolders are:

  1. docs
  2. extras/intel:
  3. platforms/android-19
  4. samples:
  5. sources/android-19
To add Android ADT into Eclipse,

Open Eclipse, if it is not.

Open Help/Install New Software from Eclipse.

Next to the "Work with", click on the "Add" button.

In the "Add Repository", enter name and location.
Then, click OK button.

In the "Available Software", click Next button.

Review the software license, then click Finish button.

By the installation is completed, you will be prompted, click Restart Now button to complete the process.





-
Name: Android ADT (or a name you like)
Location: https://dl-ssl.google.com/android/eclipse/
-

To set the Android SDK location in Eclipse,

Open Eclipse > Preference,
then click Browse button
and select the "android-sdk-macosx" folder.

Click OK button in the Preference window to save the change.


To Obtain tools and misc for Android SDK,

Open Eclipse > Window > Android SDK Manager.

Select the following (if not install yet)

  • Android SDK Tools
  • Android SDK Platform-tools
  • Android SDK Build-tools (Rev 23 and/or 19.1)
  • Android 4.4.2 (API 19) SDK Platform
  • Android 4.4.2 (API 19) Intel x86 Atom System Image
  • Android 4.4.2 (API 19) Sources for Android SDK
  • Android Support Library
  • Intel x86 Emulator Accelerator (HAXM installer)
After installation is completed, close the Android SDK Manager window. 
Then, close eclipse.
-
-


Important,
it requires manually install the Intel x86 Emulator Accelerator.

In Finder,
locate folder
/users/mydev/dev/android-sdk-macosx/extras/intel/
  Hardware_Accelerated_Execution_Manager/

Double click the file "IntelHAXM_1.1.4.dmg"

Double click on the "IntelHAXM_1.1.4.pkg".

Then, "Intel... Execution Manager", click Continue button.

see detail installation instruction here. click me

In case the site is moved,
google "Intel x86 Emulator Accelerator" for installation instruction.


aabbccbb

Set up Emulator

----
In Eclipse,
open Window > Android Virtual Device Manager.

By default, the list is empty.
Click Create button.





In Android Virtual Device (AVD) window,
enter AVD Name,
select Device, Target, CPU/ABI, Skin...etc.

Change RAM from 1907 to 1024, in case your computer do not have sufficient RAM.

Tips:
To add more choices in the CPU/ABI list, Go back to the Android SDK Manager and install.


Android SDK Manager

--

Create Hello World Android Project

----
Open Eclipse,
File > New > Others

Select "Android Application Project".
Click Next button.

In "New Android Application",
Enter Application Name, Project Name.
Change Package Name.
Change Minimum Required SDK, Target SDK, Compile With, if you like.
Click Next button.

In "Configure Project" window, do no change, and click Next button.

In "Configure Launch Icon" window, do no change, and click Next button.

In "Create Activity" window, do no change, and click Next button.

In "Blank Activity" window, do no change, and click Next button.
or change Activity Name to "HelloWorldActivity" or what you like.



-







Eclipse Project 123 - Clean, Build, and Run

----
Eclipse Project
build Step123:
1. In Eclipse,
Project > Clean
is to remove previous compiled classes/files.

Uncheck the "Start a build immediately",
and click OK button.

In Finder folder, open the
/Workspace/HelloWorld/bin/classes/
and then
/Workspace/HelloWorld/gen/

after step Clean, the folders should be empty.


2. Build
In Eclipse,
Project > Build Project

In Finder folder, open the
/Workspace/HelloWorld/bin/classes/
and then
/Workspace/HelloWorld/gen/

After step Build, now
the classes folder has filenames with extension *.class.
the gen folder has R.java and BuildConfig.java.








3. Run
In Eclipse, "Package Explorer" view, click on the "HelloWorld" project.
Then, select Run > 






Use the mouse to unlock the phone (slide-to-the-right)

Congratulation!!
You have successfully
created an Android application.

Optional:
Open the Log Cat View.

In Eclipse, select
Window > Show View > Other
then,
Android > LogCat
then, click OK button.


--

Thank you for reading, subscribe and stay tune for One day in Android Programming soon.

No comments:

Post a Comment