詹金斯 - 服务器失败的自动化的Andr​​oid UI的测试,由于主体工程的复杂的lib项目的依赖(S) [英] Failed automated Android UI-Tests on Jenkins-Server due to complex lib-project dependencies of the main project(s)

查看:139
本文介绍了詹金斯 - 服务器失败的自动化的Andr​​oid UI的测试,由于主体工程的复杂的lib项目的依赖(S)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不久summerized,我的项目结构如下所示:结果
  - A 的是Android的LIB项目,其中的的依赖的 A 的结果
  - C 的(正常的Andr​​oid项目)取决于的的结果
  - T 的是测试项目的 C

Shortly summerized, my project structure is like follows:
- A and B are android lib-projects, where B depends on A
- C (normal android project) depends on B
- T is test-project of C

我有我的詹金斯服务器上相应的两个项目,一个针对的 C 的,一个是 T 的,这对构建自己的脚本,使用实际上只是Android和蚂蚁命令。所以用的 C 的构建没有问题,但我不能得到的 T 的工作版本。

I have correspondingly two projects on my jenkins server, one for C and one for T, which have their own script for build, using actually just android and ant commands. So there is no problem with the build of C, but i can't get work build of T.

工作应该有意思是,是,根据剧本,它要么不编译或因为缺少某些类别的运行做不成,那其实是头被埋,或者不通过德兴阶段,因为中加入重复。

"Work" should there mean, that, depending on the script, it either don't compile or do fail at runtime because of some missing classes, that actually could't be, or don't pass the dexing phase because of adding duplicates.

所以,很明显,这有什么不对的依赖关系,但有趣的是,它的工作原理很漂亮的本地机器上使用Eclipse和放大器;在模拟器。

So it's clear, that there is something wrong with the dependencies, but the interesting thing is that it works very nice on local machine with eclipse & on emulator.

因此​​,这里的例子shell脚本code,那其实应该工作,并创建一个APK文件:

So here an example shell-script code, that actually should work and create an apk-file:

cd project-test
android update test-project -m ../projectC -p .
ant clean debug

这不幸导致某些类从的的,那我也要去考,无法从Java编译器发现,我总是得到错误是这样的:

This causes unfortunately that some classes from from B, that i'm also going to test, couldn't be found from the java compiler and i get always error like this:

...
[javac] Compiling 14 source files to /home/mehmed/git/project/test-project/bin/classes
[javac] SomeActivityTest.java:8: package com.mydomain.portal.android.project.activity does not exist
[javac] import com.mydomain.portal.android.project.activity.SomeClass1;
[javac]                                                        ^
[javac] SomeActivityTest.java:9: package com.mydomain.portal.android.project.data does not exist
[javac] import com.mydomain.portal.android.project.data.SomeClass2;
[javac]                                                    ^
[javac] SomeActivityTest.java:10: package com.project.portal.android.project.util does not exist
[javac] import com.mydomain.portal.android.project.util.SomeClass3;
[javac]                                                    ^
...

我曾尝试几乎一切可能解决这个问题,即使是手动编辑的project.properties文件和包括刚才的的和C在同一时间lib-像这样的项目:

I did try almost everything possible to fix that, even manually editing the project.properties file and including just B or B and C at the same time as lib-projects like this:

cd project-test
android update test-project -m ../projectC -p .
echo "android.library.reference.1=../projectB" >> project.properties
# or even also projectA:
echo "android.library.reference.2=../projectA" >> project.properties
ant clean debug

这导致这次德兴由于重复的错误从LIB项目添加类。

which results this time in dexing errors because of duplicate adding of the classes from lib-projects.

有人是否有有关解决这个任何想法?感谢您提前帮助!

Does somebody have any ideas about fixing this? Thanks for help in advance!

推荐答案

在您的测试项目的 T ,如果你有SomeActivityTest明确导入/使用一些包/班从图书馆计划中的和/或 C ,您必须添加库项目作为试验项目的依赖,被引用的包/类是需要在项目生成时间。如果你不这样做,你会当你编译收到以下错误测试项目:

In your Test Project T, if you have SomeActivityTest that explicitly import/use some package/class from Library Project B and/or C, you have to add the Library Project as a dependency of Test project, as the referenced package/class is required at project build time. if you don't, you will get the following error when compile you Test Project:

[javac] SomeActivityTest.java:8: package com.mydomain.portal.android.project.activity does not exist
[javac] import com.mydomain.portal.android.project.activity.SomeClass1;
[javac]                                                        ^
[javac] SomeActivityTest.java:9: package com.mydomain.portal.android.project.data does not exist

如果您添加图书馆项目在这两个主项目和测试项目的依赖,并使用Ant构建你的测试项目,它德兴步导致重复的条目。 Eclipse的ADT插件知道如何正确hanlde这种情况下,这样你就不会得到这个麻烦,当构建与Eclipse:

If you add Library Project as dependency in both Main Project and Test Project, and use Ant build you test project, it cause duplicate entries at dexing step. Eclipse ADT plugin knows how to hanlde this situation properly so you don't get this trouble when build with Eclipse:

[dx] UNEXPECTED TOP-LEVEL EXCEPTION:
[dx] java.lang.IllegalArgumentException: already added: Lcom/mydomain/...;
[dx]     at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[dx]     at com.android.dx.dex.file.DexFile.add(DexFile.java:163)

目前,有解决方法(在Ant脚本脏修复),检查出我的答案<一个href=\"http://stackoverflow.com/questions/9513517/unexpected-top-level-exception-after-sdk-update\">here了解详情。

Currently, there is a workaround (dirty fix in ant script), check out my answer here for details.

请注意,最近的SDK版本R17其中有许多bug修复和改进。按照的changelog ,它声称现在SDK可以处理重复的依赖更聪明,虽然我还没有'T累了自己与测试项目呢。也许你可以给它一个镜头,看看它是否工作。希望这有助于。

Note that the most recent SDK release r17 which got many bug fix and improvement. According to the changelog, it claims that now SDK can deal with duplicate dependencies more smarter, although I haven't tired myself with Test Project yet. Probably you can give it a shot and see if it works. Hope this helps.

这篇关于詹金斯 - 服务器失败的自动化的Andr​​oid UI的测试,由于主体工程的复杂的lib项目的依赖(S)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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