android中生成和使用jar

  参考资料1: http://blogold.chinaunix.net/u/9577/showart_1826330.html

    

  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)
  3. xxx

   通过上面的方法能够生成jar,使用的时候compile也能成功,但是运行的时候会出错,原因是需要用到的jar没有打包到apk里面。要把jar打包到apk里面还需要下面的步骤。

   参考资料2:http://topic.csdn.net/u/20091118/16/5a27d8e7-d8a2-43b3-92db-9d88ff8f7bec.html

   

1、在Android项目根目录下新建一个libs文件夹;
2、把你需要的导入的第三方Jar包复制进这个目录;
3、在libs目录上点右键,选Bulid path –> Use as source folder。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值