2007 2013 Kandroid
www.kandroid.org »
kandroid s/w fundamentals 교육 »
Android Open Source 
▶ HTC Android Kernel Open Source
▶ Samsung Android Kernel Open Source
▶ Motorola Android Kernel(+α) Open Source
▶ LGE Android Kernel(+α) Open Source
안드로이드 플랫폼 개발을 위해 Eclipse 사용하기
작성자 들풀
작성일 2008-12-07 (일) 08:29
ㆍ추천: 0  ㆍ조회: 8329      
IP: 125.xxx.181
출처 : http://source.android.com/using-eclipse  
 

Using Eclipse

About this Document

This document will help you set up the Eclipse IDE for Android platform development.


Enter eclipse

Basic setup

First, it's important to make sure the regular Android development system is set up.
cd /path/to/android/root
make # and wait a while, if you haven't done this
Important: You will still be using "make" to build the files you will actually run (in the emulator or on a device).
You will be using Eclipse to edit files and verify that they compile, but when you want to run something you will
need to make sure files are saved in Eclipse and run "make" in a shell. The Eclipse build is just for error checking.
Eclipse needs a list of directories to search for Java files. This is called the "Java Build Path" and can be set
with the .classpath file. We have a sample version to start you off.
cd /path/to/android/root
cp development/ide/eclipse/.classpath .
chmod u+w .classpath # Make the copy writable
Now edit that copy of .classpath, if necessary.
Increase Eclipse's Memory Settings
The Android project is large enough that Eclipse's Java VM sometimes runs out of memory while compiling it.
Avoid this problem by editing the the eclipse.ini file. On Apple OSX the eclipse.ini file is located at
/Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini
Memory-related defaults (as of Eclipse 3.4)

-Xms40m
-Xmx256m
-XX:MaxPermSize=256m
Recommended settings for Android development
-Xms128m
-Xmx512m
-XX:MaxPermSize=256m
These settings set Eclipse's minimum Java heap size to 128MB, set the maximum Java heap size to 512MB,
and keep the maximum permanent generation size at the default of 256MB.
Now start Eclipse:
eclipse  # or you can click some clicky thing instead, if you prefer
Now create a project for Android development:
  1. If Eclipse asks you for a workspace location, choose the default.
  2. If you have a "Welcome" screen, close it to reveal the Java perspective.
  3. File > New > Java Project
  4. Pick a project name, "android" or anything you like.
  5. Select "Create project from existing source", enter the path to your Android root directory, and click Finish.
  6. Wait while it sets up the project. (You'll see a subtle progress meter in the lower right corner.)
Once the project workspace is created, Eclipse should start building. In theory, it should build with no errors
and you should be set to go. If necessary, uncheck and re-check Project > Build Automatically to force a rebuild.
Note:   Eclipse sometimes likes to add an "import android.R" statement at the top of your files that use resources,
especially when you ask eclipse to sort or otherwise manage imports. This will cause your make to break.
Look out for these erroneous import statements and delete them.

When you sync

Every time you repo sync, or otherwise change files outside of Eclipse (especially the .classpath), you need to
refresh Eclipse's view of things:
  1. Window > Show View > Navigator
  2. In the "Navigator", right-click on the project ("android-java" or whatever you named it)
  3. Click Refresh in the context menu
여기까지의 내용을 활용하여, 안드로이드 Native Apk.들을 개발하기 위한 환경으로 활용하는 것은 의미가 있을 듯 하지만,
문제는 Apk의 UI를 실시간으로 에뮬레이터를 통해 테스트 할 수 없다는 한계가 분명히 존재하는 군요.
좀 더 좋은 방법을 찾아봐야할듯 하네요.
 
※ 이 아래의 영역은 제 생각으로는 특별히 유용하지 않을 듯 합니다.(들풀)


Adding apps to the build path

The default .classpath includes the source to the core system and a sample set of apps, but might not include
the particular app you may want to work on. To add an app, you must add the app's source directory.
To do this inside Eclipse:

  1. Project > Properties
  2. Select "Java Build Path" from the left-hand menu.
  3. Choose the "Source" tab.
  4. Click "Add Folder...".
  5. Add your app's "src" directory.
  6. Click OK.
When you're done, the "source folder" path in the list should look like android/packages/apps/YourAppName/src.
Depending on which app(s) you include, you may also need to include other src/main/java directories under
android/dalvik/libcore. Do this if you find you cannot build with the default set.

Eclipse setup to work on developer tools

To work on Java developer tools, the principle is the same, except you specify /path/to/tool when using the
option "Create project from existing source."
Once the project is created, you need to set up the Java Build Path:

  1. Select the project you just created.
  2. Project > Properties
  3. Select "Java Build Path" from the left-hand menu.
  4. Choose the "Source" tab.
  5. Expand the single toolname/src entry.
  6. Double click the "Excluded: (none)" item.
  7. Add to the excluded (bottom) list: "MakeFile" and "resources/".
  8. Close the dialog.
  9. Back in the "Source" tab, click "Add Folder...", and add toolname/src/resources.
  10. Click OK.

Eclipse setup to work on DDMS

For DDMS, you will need to make a project for
  1. development/tools/ddms/libs/ddmlib
  2. development/tools/ddms/libs/ddmuilib
  3. development/tools/ddms/app
Each project will need to reference the ones before it ("ddmuilib" references "ddmlib", and "app" references
both of those). To do this:

  1. Make sure you have all 3 projects defined.
  2. Right click on a project, "Build Path" > "Configure Build Path..."
  3. Choose the "Project" tab.
  4. Click "Add..." and check the required projects.

Eclipse formatting

You can use a preference file in Eclipse to automatically set the formatter to the Android style guide.  Import
the files android-formatting.xml and android.importorder, which live under development/ide/eclipse.

Debugging the emulator with Eclipse

You can also use eclipse to debug the emulator and step through code. First, start the emulator running:
cd /path/to/android/root
. build/envsetup.sh
lunch 1 # to build the emulator
make # if you didn't already do this
emulator # you should see a GUI picture of a phone
In another shell, start DDMS (the Dalvik debug manager):
cd /path/to/android/root
ddms # you should get a splufty debugging console
Now, in eclipse, you can attach to the emulator:
  1. Run > Open Debug Dialog...
  2. Right-click "Remote Java Application", select "New".
  3. Pick a name, "android-debug" or anything you like.
  4. Set the "Project" to your project ("android-java" or whatever).
  5. Keep the "Host" set to "localhost", but change "Port" to 8700.
  6. Click the "Debug" button and you should be all set.
Note that port 8700 is attached to whatever process is currently selected in the DDMS console, so you need
to sure that DDMS has selected the process you want to debug.
You may need to open the Debug perspective (next to the "Java" perspective icon in the upper-right, click the

small "Open Perspective" icon and select "Debug"). Once you do, you should see a list of threads; if you
select one and break it (by clicking the "pause" icon), it should show the stack trace, source file, and line
where execution is at. Breakpoints and whatnot should all work.

Bonus material

Replace Ctrl with the Apple key on Mac.

Ctrl-Shift-o = Organize imports
Ctrl-Shift-t = load class by name
Ctrl-Shift-r = load non-class resource by name
Ctrl-1 = quick fix
Ctrl-e = Recently viewed files
Ctrl-space = auto complete
Shift-Alt-r = refactor:rename
Shift-Alt-v = refactor:move

Useful Plugins

Eclipse has a plugin architecture that enables third parties to extend the IDE. Here are some plugins that
make Eclipse easier to use for writing Android software:


  • AnyEdit - automatically fix whitespace issues when saving files. Can convert tabs to spaces, strip
    blanks at end-of-line, and ensure the last line of the file has an end-of-line character.

"Eclipse is not working correctly, what should I do?"

Make sure:
  • You followed the instructions on this page precisely.
  • Your Problems view doesn't show any errors.
  • Your application respects the package/directory structure.
If you're still having problems, please contact one of the Android mailing lists or IRC channels
덧글 쓰기 0
32000
※ 회원등급 레벨 0 이상 읽기가 가능한 게시판입니다.
    N     분류     제목    글쓴이 작성일 조회
65 9회 kandroid 컨퍼런스를 기다리며~ [10]+8 행복아 2012-02-01 2436
64 안드로이드 전체소스의 맵(OS+플랫폼) [8]+7 인베인 2012-01-19 6039
63 안드로이드 그래픽스와 9회 kandroid 컨퍼런스 들풀 2012-01-04 2434
62 ICS4.0 (Prelink와 ASLR)와 9회 kandroid 컨퍼런스 [2]+3 들풀 2012-01-04 3025
61 [완결] 안드로이드 커널피쳐가 리눅스 메인라인에 들어오다... [4]+3 인베인 2011-12-20 2786
60 새로운 안드로이드버젼(ICS)의 공식 git 저장소 [3]+4 인베인 2011-12-19 9042
59 Gif파일 만들기 [2] 별찌 2011-12-05 1763
58 [덧글필독]안드로이드 system_server 디버깅 기법 [2]+8 들풀 2011-10-23 5857
57 ICS버젼 쓰레드의 TLS 동작구조(ver 0.3) [6]+10 인베인 2011-10-18 4293
56 [Android-MMF] 안드로이드 미디어 프레임워크의 개요 - 04.. [4]+1 소오강호 2011-05-29 8357
55 [Android-MMF] 안드로이드 미디어 프레임워크의 개요 - 03.. [2] 소오강호 2011-05-29 7537
54 [Android-MMF] 안드로이드 미디어 프레임워크의 개요 - 02.. [4] 소오강호 2011-05-14 7429
53 [Android-MMF] 안드로이드 미디어 프레임워크의 개요 - 01.. [9]+1 소오강호 2011-05-10 13136
52 안드로이드 Gingerbread Source Open 및 Build [6]+3 lesmin 2010-12-20 9704
51 Optimus-Q 리눅스 커널 오픈소스 URL [1] onjo 2010-10-01 4632
50 Galaxy-S 리눅스 커널 오픈소스 URL [2] 들풀 2010-07-21 9812
49 안드로이드 Froyo Source Open [5]+1 lesmin 2010-06-24 11801
48 안드로이드 내장 APKs 개발방법(초안) [28]+20 들풀 2010-03-05 33771
47 모토로이 소스 공개 [7]+3 Beto 2010-03-01 14874
46 안드로이드 2.1 Source Open [3]+2 자하랑 2010-01-21 12557
45 Android 1.6 브랜치 업데이트(1.3->1.4) [2]+1 인베인 2009-10-24 3769
44 SH4 CPU 아키텍쳐 지원을 위한 Android [2]+1 인베인 2009-09-17 4603
43 Samsung Galaxy 안드로이드 커널 빌드 [7]+14 들풀 2009-09-15 10934
42 Online PDK(Platform Dev. Kit) - donut [2]+1 들풀 2009-09-01 4784
41 MIPS용 안드로이드 소스코드 릴리즈 및 빌드방법.. [4]+6 인베인 2009-08-11 8872
40 iPAQ HX4700 PDA에 안드로이드를 포팅하자 [9] 좋은이 2009-08-10 8101
39 CENTOS 5.5에서 Android PDK설치방법 (Froyo브랜치) [1] 인베인 2009-07-27 13087
38 Ubuntu 9.04 + Android 1.5 Build [4] bluedisk 2009-05-06 8530
37 Android Porting on x86 PC [10]+1 SPARC 2009-04-29 10433
36    Re.. 질문이요. VBoxManage convertfromraw 문제 [8] coojin 2009-05-15 10273
35 Create AVDs for SDK 1.5 [1] 이광우 2009-04-28 10325
34 [빙고]1.5 SDK Win & Linux 링크입니다 참고하세요 [13]+10 와이드오픈 2009-03-10 5110
33 ADT 0.9 Cupcake 용 [5] 자하랑 2009-02-10 3622
32    Re..No resource identifier found for attribute... [2] Leone 2009-02-18 4874
31 X86용으로 안드로이드 포팅하기(on Virtualbox) [7]+2 인베인 2009-02-09 10246
30 REAL TARGET BOARD 없이 안드로이드 포팅기술 익히기.. [17]+15 좋은이 2009-01-30 14974
29    Re..REAL TARGET BOARD 없이 안드로이드 포팅기술 익히기.. [4]+2 NPain 2009-03-21 5441
28    Re..REAL TARGET BOARD 없이 안드로이드 포팅기술 익히기.. [5] 딱신 2009-03-18 3836
27 Dalvik JNI 를 이용한 cpp 함수 추가 및 SDK 에서 사용하기.. [9] unbiari 2008-12-26 8422
26 안드로이드 전체소스 빌드(For X86) - Fedora 사용자.. [3] 인베인 2008-12-24 17562
25    Re..ASUS/EEE LapTop PC의 플랫폼 드라이버 코드 [2] 인베인 2009-02-09 2661
24    Re..안드로이드 전체소스 빌드(For X86) - Fedora 사용자.. 인베인 2008-12-29 3061
23 안드로이드 전체소스 빌드(For X86) - Ubuntu사용자.. [14] 인베인 2008-12-24 11793
22 안드로이드 Native Development Kit(NDK) 사용법 [18]+3 들풀 2008-12-11 16772
21    Android NDK r3 공식 릴리즈 [3]+1 들풀 2010-03-09 4236
20    Re..android-ndk-1.6_r1 미리보기 [3]+1 들풀 2009-09-20 3699
19    Re.. android-ndk-1.5_r1 사용법 [windows] [7]+3 들풀 2009-06-29 8961
18 안드로이드 SDK Build 방법 [5] 들풀 2008-12-09 12032
17 Android Porting Guide for TI OMAP Zoom [1] 들풀 2008-12-07 4885
16 Git Community Book [3] 들풀 2008-12-07 3377
15 android build system [8]+2 베이징숀 2008-11-19 8232
14 Android Telephony for CDMA [1] 들풀 2008-11-28 4482
13 안드로이드 PDK (Platform Development Kit) [1] 들풀 2008-10-28 7954
12 Mac OS에서 Android 소스 받기 및 빌드 [10]+5 ratharn 2008-10-27 8880
11 Android 전체소스 빌드 방법(For ARM) on Fedora 배포판 -2008.. [8]+1 invain 2008-10-26 10698
10    Re.. Fedora배포판에서 Cupcake빌드시의 TroubleShooting.. 인베인 2010-03-18 3518
9 [Samsung SC32442]용 Android 소스 빌드 [7] 들풀 2008-10-26 7338
8    Re.. sc32442 안드로이드 탑재 screen shot [15]+5 들풀 2009-01-12 3628
7    Neo 1973 phone [9] 들풀 2008-11-06 3419
6 안드로이드 전체 소스 코드 빌드 방법 [54]+7 들풀 2008-10-24 45648
5    HTC_DREAM Build (Donut) [6]+1 불타는주작 2009-08-04 3651
4    안드로이드 cupcake 빌드방법 [5]+5 들풀 2009-01-28 6362
3    안드로이드 플랫폼 개발을 위해 Eclipse 사용하기.. 들풀 2008-12-07 8329
2    안드로이드 소스 코드 빌드 테스트 [8]+1 들풀 2008-10-27 8518
1 안드로이드 오픈 소스 [7] 들풀 2008-10-22 12985
1