2010年9月30日 星期四

[轉貼] [Android] JAR Library: Export and Import

原文標題: [Android] JAR Library: Export and Import
原文作者: web_surf@163.com
發表日期: 2010-06-18 09:42
原文來源: https://bbs.et8.net/bbs/showthread.php?t=616987

1.Export Library
* Prepare source code
- Create an Android project
- Create source code, and fix all bug
- Remove res/*
- Remove unused source files
- Edit AndroidManifest.xml to remove the statements that referes to resource, such as android:icon="@drwable/icon", android:label="@string/app_name"
    * Export library
    - On Package Explorer Panel of Eclipse, right-click the project, and select Export
    - Select Jave -> JAR file, then press "Next". At this time a dialog pops up.
    - On the right panel of "Select the resources to export:" group, unselect all items (such as .classpath, .project, AndroidManifest.xlm, default.properties), then press "Next"
    Press "Next"
    Press "Finish"

    Then the library is created.
    (Reference: Eclipse export jar files http://hi.baidu.com/etrigger/blog/item/e1fed134468b2fb2d0a2d3ad.html)
    * xxx

    2.Import Library
    You can use a third party JAR in your application by adding it to your Eclipse project as follows:
    - In the Package Explorer panel, right-click on your project and select Properties.
    - Select Java Build Path, then the tab Libraries.
    - Press the Add External JARs... button and select the JAR file

    Alternatively, if you want to include third party JARs with your package, create a new directory for them within your project and select Add Library... instead.
    It is not necessary to put external JARs in the assets folder.
    (Reference: http://code.google.com/intl/zh-CN/android/kb/commontasks.html)


    簡單的作法是靠Eclipse的Project->Export, 僅選取src的部份, 匯出即可
    Import還是靠Eclipse的Project->Properties->Java Build Path->Libraries->Add External JARs即可

    沒有留言: