Android 测试项目在 Ant 下构建失败,在 Eclipse 中 OK [英] Android test project fails to build under Ant, OK in Eclipse

查看:27
本文介绍了Android 测试项目在 Ant 下构建失败,在 Eclipse 中 OK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 Android 应用项目及其 JUnit 测试项目设置 CI 构建服务器.我已经为应用和测试项目生成了适当的 build.xml 文件.

I am trying to set up a CI build server for an Android app project and its JUnit test project. I've generated the appropriate build.xml files for both app and test projects.

两个项目都在 Eclipse 下构建和执行良好.

Both projects build and execute fine under Eclipse.

但是,当我尝试对测试项目进行 ant debug 没有先用 Eclipse 构建两个项目,我得到了几个 [javac] 错误提示 error: cannot find symbol 引用应用项目中的类.

However, when I try to do ant debug on the test project without having first built both projects with Eclipse, I get several [javac] errors saying error: cannot find symbol which refer to classes in the app project.

认为这是 Eclipse 看到的类路径与 Ant 使用的类路径之间的区别...

I think this is a difference between the classpath that Eclipse sees and the classpath that Ant is using...

如何告诉 Ant 在哪里可以找到应用程序类?

How do I tell Ant where to find the app classes?

似乎Android默认build.xml定义了所有目标,所以我想知道如何在应用程序项目的build.xml中插入适当的引用...而不必从头开始构建文件.

It seems the Android default build.xml defines all the targets, so I was wondering how to insert the appropriate reference in the app project's build.xml... rather than having to start the build file from scratch.

  1. 尝试从 Eclipse 导出 Ant 构建文件;无法构建任一项目.

推荐答案

似乎有效的是重新运行:

What seems to work is to re-run:

android update test-project -m ../../app_project/-p .

在测试项目中.

它所做的唯一更改是创建一个带有一个非注释行的 ant.properties 文件:

The only change it made was to create an ant.properties file with one non-comment line:

tested.project.dir=../../app_project/

现在这一切都可以在 Eclipse 之外顺利运行!

And now it all works swimmingly outside of Eclipse!

这篇关于Android 测试项目在 Ant 下构建失败,在 Eclipse 中 OK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆