허니몬의 IT 이야기/프로그래머, '코드 엔지니어'

 

 

Android 설치방법 및 예제실행#

관련링크 : http://developer.android.com/sdk/1.6_r1/installing.html#installingplugin

 

  • 설정하기(Linux의 경우)#

    • .bash_profile or .bashrc 파일을 연다.
    • export PATH 항목이 있으면, 끝에 설치경로/tools 를 추가하면 된다.
    • export PATH 항목이 없으면, export PATH=${PATH}:<your_sdk_dir>/tools 를 추가한다.

 

  • 이클립스에 ADT Plugin 설치하기#

Eclipse 3.4 (Ganymede) Eclipse 3.5 (Galileo)
  1. Start Eclipse, then select Help > Software Updates.... In the dialog that appears, click the Available Software tab.
  2. Click Add Site...
  3. In the Add Site dialog that appears, enter this URL in the "Location" field:
    https://dl-ssl.google.com/android/eclipse/
    

    Note: If you have trouble aqcuiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).

    Click OK.

  4. Back in the Available Software view, you should see the plugin listed by the URL, with "Developer Tools" nested within it. Select the checkbox next to Developer Tools and click Install...
  5. On the subsequent Install window, "Android DDMS" and "Android Development Tools" should both be checked. Click Next.
  6. Read and accept the license agreement, then click Finish.
  7. Restart Eclipse.
  1. Start Eclipse, then select Help > Install New Softare.
  2. In the Available Software dialog, click Add....
  3. In the Add Site dialog that appears, enter a name for the remote site (e.g., "Android Plugin") in the "Name" field.

    In the "Location" field, enter this URL:

    https://dl-ssl.google.com/android/eclipse/
    

    Note: If you have trouble aqcuiring the plugin, you can try using "http" in the URL, instead of "https" (https is preferred for security reasons).

    Click OK.

  4. Back in the Available Software view, you should now see "Developer Tools" added to the list. Select the checkbox next to Developer Tools, which will automatically select the nested tools Android DDMS and Android Development Tools. Click Next.
  5. In the resulting Install Details dialog, the Android DDMS and Android Development Tools features are listed. Click Next to read and accept the license agreement and install any dependencies, then click Finish.
  6. Restart Eclipse.

위의 방법을 잘 따라하면 된다. ^^, 이클립스 재시작

 

  • 이클립스 설정하기#

    01. Preferences -> Android 클릭 : SDK Location 에 Android 설치한 위치를 연다.#

    02. Apply or OK 를 클릭한다.#

 

  •  Create an AVD(Android Virtual Device) : 안드로이드용 가상 장치(my_avd)를 생성하는 과정입니다.#

 

  1. android create avd --target 2 --name my_avd

 

Android 1.6 is a basic Android platform.

Do you wish to create a custom hardware profile [no]  // 엔터

Created AVD 'my_avd' based on Android 1.6, with the following hardware config:

hw.lcd.density=160

--target option is required and specifies the deployment target to run on the emulator.
--name option is also required and defines the name for the new AVD.

 

 

 

  • Android 입문 따라하기 : Hello, Android 출력하기#

관련링크 : http://developer.android.com/guide/tutorials/hello-world.html

 

01. Android Project 생성하기(File -> New -> Project)#

Android_Project_Create_01.png

 

02. Android -> Android Project 선택#

Android_Project_Create_02.png

 

  • Project name: HelloAndroid
  • Application name: Hello, Android
  • Package name: com.example.helloandroid (or your own private namespace)
  • Create Activity: HelloAndroid
  • Min SDK Version: 4

 

각 항목별 설명 - 해석은 나중에#

 

Project Name // 프로젝트 명칭 - 이클립스에서 나타나는 프로젝트 이름 
This is the Eclipse Project name — the name of the directory that will contain the project files.
Application Name // 응용프로그램 명칭 - 사용자가 인식할 수 있는 것이며, Android 장치의 이름을 표현
This is the human-readable title for your application — the name that will appear on the Android device.
Package Name //

This is the package namespace (following the same rules as for packages in the Java programming language) that you want all your source code to reside under. This also sets the package name under which the stub Activity will be generated.

Your package name must be unique across all packages installed on the Android system; for this reason, it's very important to use a standard domain-style package for your applications. The example above uses the "com.example" namespace, which is a namespace reserved for example documentation — when you develop your own applications, you should use a namespace that's appropriate to your organization or entity.

Create Activity
This is the name for the class stub that will be generated by the plugin. This will be a subclass of Android's Activity class. An Activity is simply a class that can run and do work. It can create a UI if it chooses, but it doesn't need to. As the checkbox suggests, this is optional, but an Activity is almost always used as the basis for an application.
Min SDK Version
This value specifies the minimum API Level required by your application. If the API Level entered here matches the API Level provided by one of the available targets, then that Build Target will be automatically selected (in this case, entering "2" as the API Level will select the Android 1.1 target). With each new version of the Android system image and Android SDK, there have likely been additions or changes made to the APIs. When this occurs, a new API Level is assigned to the system image to regulate which applications are allowed to be run. If an application requires an API Level that is higher than the level supported by the device, then the application will not be installed.

 

03. Finish 클릭#

04. 생성된 프로젝트를 열어보면 다음과 같다.#

Android_Project_Create_03.png

04. HelloAndroid.java 내용#

 

package com.example.helloandroid;

import android.app.Activity;
import android.os.Bundle;

public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

05. 실행 클릭#

Android_Create_Project_04.png

06. 실행된 모습 - 에뮬레이터 상단에 보면 my_avd 가 보일 것이다. 아까 Create an AVD 에서 생성된 안드로이도 가상 장치 명칭임.#

- 실행되는데 시간은 컴퓨터 마다 다를 것 같다.

Android_Project_Create_05.png

07. Android 실행모습#

Android_00.png

Hello, Android 출력화면.

Android_01.png Android_02.png Android_04.png Android_05.png Android_06.png

Android_07.png

시스템 종료 모습

이 글은 스프링노트에서 작성되었습니다.