1

我正在尝试准备使用 selendroid-standalone 来处理与手机的连接的测试用例。该项目使用 Maven 并包含几个子模块,因此我在顶部 pom.xml 中添加了这样的依赖项:
<dependency> <groupId>io.selendroid</groupId> <artifactId>selendroid-standalone</artifactId> <scope>compile</scope> <type>jar</type> <version>0.5.1</version> </dependency>

之后,当我尝试编译它时,我收到这样的错误: Error adding archived file-set. PlexusIoResourceCollection not found for: d:\XXX\selendroid-server-0.5.1.apk: No such archiver: 'apk'.

我试图将依赖项移至子模块,但随后在我使用的行SelendroidConfiguraion或包中的其他类处出现 NoClassDefFoundError。

编辑:添加任何其他依赖项都不会出现 NoClassDefFoundError。

4

2 回答 2

1

您需要指定您自己的程序集,以阻止 Maven 尝试解包然后重新打包 apk 文件的内容。网上有很多关于这样做的教程(通常用于 swfs 或 zips),但我只是通过指定以下内容来做到这一点:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">  
  <id>jar-with-dependencies</id>
  <formats>
    <format>jar</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <dependencySets>
    <dependencySet>
      <outputDirectory>/</outputDirectory>
      <useProjectArtifact>true</useProjectArtifact>
      <unpack>true</unpack>
      <scope>runtime</scope>
      <excludes>
        <exclude>*:apk:*</exclude>
      </excludes>
    </dependencySet>
  </dependencySets>
  <fileSets>
    <fileSet>
      <directory>${project.build.outputDirectory}</directory>
      <outputDirectory>.</outputDirectory>
    </fileSet>
  </fileSets>
</assembly>

将它保存在它自己的 XML 文件中,然后将你的 POM 指向这个而不是默认的程序集描述符:

<!-- disabled predefined assembly 
<descriptorRefs>
    <descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
-->
<descriptors>
       <descriptor>src/main/assembly/assembly-descriptor.xml</descriptor>
</descriptors>
于 2016-07-28T15:44:57.323 回答
0

我在 pom.xml 中使用了不同的依赖版本:

<dependency>
  <groupId>io.selendroid</groupId>
  <version>0.8.0</version>
  <artifactId>selendroid-standalone</artifactId>
</dependency>
<dependency>
  <groupId>io.selendroid</groupId>
  <version>0.8.0</version>
  <artifactId>selendroid-client</artifactId>
</dependency>

(您甚至可以查看此页面以获取更多信息:http ://selendroid.io/quickStart.html )

于 2014-03-08T05:49:19.563 回答