<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-348  評論-598  文章-0  trackbacks-0
    明天應該就能閃了,一個月,收獲頗豐阿,哈哈。

    Using Eclipse

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

    Note: if you are looking for information on how to use Eclipse to develop applications that run on Android, this is not the right page for you. You probably would find the Eclipse page on developer.android.com more useful.

    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

    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 othersrc/main/java directories under android/dalvik/libcore. Do this if you find you cannot build with the default set.

    Eclipse formatting

    You can import files in development/ide/eclipse to make Eclipse follow the Android style rules. Select "Window › Preferences › Java › Code Style". Use "Formatter › Import" to import android-formatting.xml and "Organize Imports › Import" to import android.importorder.

    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

    "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.



    ---------------------------------------------------------
    專注移動開發

    Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
    posted on 2010-09-16 07:43 TiGERTiAN 閱讀(579) 評論(0)  編輯  收藏 所屬分類: Android
    主站蜘蛛池模板: 久久精品免费电影| 夭天干天天做天天免费看| 亚洲视频在线观看不卡| 国内免费高清在线观看| 青青青视频免费观看| 亚洲丁香色婷婷综合欲色啪| 妞干网免费观看视频| a级毛片免费在线观看| 亚洲一区在线免费观看| 亚洲国产精品碰碰| 亚洲视频在线免费播放| 精品在线观看免费| 亚洲欧洲校园自拍都市| 亚洲国产日韩成人综合天堂| 最刺激黄a大片免费网站| 国产成人高清亚洲一区久久| 久久精品亚洲精品国产色婷 | 99在线观看视频免费| 欧美亚洲精品一区二区| 久久亚洲精品人成综合网| 深夜国产福利99亚洲视频| 亚欧免费视频一区二区三区| 国产JIZZ中国JIZZ免费看| 2020久久精品亚洲热综合一本| 亚洲精品无码久久千人斩| 免费黄网在线观看| 69av免费观看| 国产好大好硬好爽免费不卡| 国产精品亚洲色图| 亚洲中字慕日产2021| 好看的亚洲黄色经典| 免费久久精品国产片香蕉| 131美女爱做免费毛片| 成人av片无码免费天天看| 亚洲av日韩av永久无码电影| 亚洲a一级免费视频| 中文字幕亚洲天堂| 国产一区在线观看免费| 成年女性特黄午夜视频免费看| 亚洲免费在线视频| 成人爽a毛片免费|