---
title: "如何打包引入第三方的UIAutomator项目"
author: "qi_ling2005"
date: "2016-06-14T16:16:25Z"
tags: []
categories: ["移动开发"]
slug: "uiautomator"
draft: false
lastmod: "2016-06-14T16:16:25Z"
id: 2305014
url: "https://jarvi.iteye.com/blog/2305014"
---

项目下新建custom\_rules.xml文件

内空：

```
<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules" default="release">
	<!-- Include external libs -->
	<property name="jar.libs.dir" value="libs" />
	<property name="jar.libs.absolute.dir" location="${jar.libs.dir}" />
	<path id="classpath">
		<fileset dir="${jar.libs.absolute.dir}">
			<include name="**/*.jar" />
		</fileset>
	</path>

	<!-- overwrite the compile target in uibuild.xml to include to external 
		jars -->
	<target name="compile" depends="-build-setup, -pre-compile">
		<javac encoding="${java.encoding}" source="${java.source}"
			target="${java.target}" debug="true" extdirs="" includeantruntime="false"
			destdir="${out.classes.absolute.dir}" bootclasspathref="project.target.class.path"
			verbose="${verbose}" fork="${need.javac.fork}">
			<src path="${source.absolute.dir}" />
			<classpath refid="classpath" />
			<compilerarg line="${java.compilerargs}" />
		</javac>
	</target>

	<!-- Converts this project's .class files into .dex files -->
	<target name="-dex" depends="compile, -post-compile">
		<dex executable="${dx}" output="${intermediate.dex.file}"
			nolocals="@{nolocals}" verbose="${verbose}">
			<fileset dir="${jar.libs.absolute.dir}">
				<include name="**/*.jar" />
			</fileset>
			<path path="${out.classes.absolute.dir}" />
		</dex>
	</target>

</project>
```

 

这样就ok了。 

 

参考：

 

# [Adding external jars to an Android UIautomator project](http://stackoverflow.com/questions/16026355/adding-external-jars-to-an-android-uiautomator-project)

# [Ant如何打包UIAutomator项目用到的第三方JAR包](http://www.2cto.com/kf/201409/337841.html)