[Android分享] Android中用Ant把ndk的so文件打包进apk

在用ant进行打包apk文件时,如果用到ndk,那么如何把so文件打包进去呢?
其实很简单,就在target为package的xml段里加上这2行
<arg value="-nf"/>
<arg value="${external-lib-ospath}" />
其中${external-lib-ospath}" 的值为libs,记住不要写libs/armeabi
附上该段的xml代码:
<target name="package" depends="dex, package-res-and-assets">
  <echo>Packaging unsigned apk for release...</echo>
  <exec executable="${apkbuilder}" failonerror="true">
   <arg value="${out-unsigned-package-ospath}" />
   <arg value="-u" />
   <arg value="-z" />
   <arg value="${resources-package-ospath}" />
   <arg value="-f" />
   <arg value="${dex-ospath}" />
   <arg value="-rf" />
   <arg value="${srcdir-ospath}" />
    
   <arg value="-nf"/>
   <arg value="${external-lib-ospath}" />

  
  </exec>
  <echo>It will need to be signed with jarsigner before being published.</echo>
</target>

 

http://www.eoeandroid.com/forum.php?mod=viewthread&tid=233945

你可能感兴趣的:(android)