android 打包第三方jar包

android项目开发时会用到第三方提供的jar包,通常情况下按照eclipse导入jar包的方法(选择项目,右键点击Build Path,Build Path–>Add Libraries–>User Library–>Next–>User Libraries–>New–>Add JARs,选择第三方的jar包),就可以将jar包导入到项目。

根据这样的打包方式时,eclipse导入jar包后,eclipse编译器也能识别,即项目不会因为缺少jar包而报错,但是运行android程序的时候却没有找到包而报错了。APK文件也很小,也就是jar包并没有打包到APK文件中。

在android项目中找到.classpath文件并打开,文件代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry kind="lib" path="E:/Code/android/Lib/MapApi.jar"/>
    <classpathentry kind="lib" path="E:/Code/android/Lib/xpp3_min-1.1.4c.jar"/>
    <classpathentry kind="lib" path="E:/Code/android/Lib/xstream-for-android-1.0.0.jar"/>
    <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

发现如下一行包含有exported

 <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>

如是我想,是不是lib中也要加呢,修改为如下:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry exported="true" kind="lib" path="E:/Code/android/Lib/MapApi.jar"/>
    <classpathentry exported="true" kind="lib" path="E:/Code/android/Lib/xpp3_min-1.1.4c.jar"/>
    <classpathentry exported="true" kind="lib" path="E:/Code/android/Lib/xstream-for-android-1.0.0.jar"/>
    <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

在打包,文件变大了,呵呵,应该文件打包进去了。

经过测试,确实成功了,只是下一步想知道怎么在eclipse中设置。

转载于:https://www.cnblogs.com/lexloo/archive/2012/09/26/2703536.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值