Lucas Wa
Lucas Wa

Reputation: 530

Selendroid with Maven: No such archiver: 'apk'

I am trying to prepare test case which uses selendroid-standalone to handle connection to mobile phone. The project uses Maven and contains several submodules, so I have added such dependency to top pom.xml:
<dependency> <groupId>io.selendroid</groupId> <artifactId>selendroid-standalone</artifactId> <scope>compile</scope> <type>jar</type> <version>0.5.1</version> </dependency>

After that when I try to compile it I get such error: Error adding archived file-set. PlexusIoResourceCollection not found for: d:\XXX\selendroid-server-0.5.1.apk: No such archiver: 'apk'.

I tried to move the dependency to submodule but then I have NoClassDefFoundError at lines where I use SelendroidConfiguraion or other classes from the package.

EDIT: Adding any other dependency works with no NoClassDefFoundError.

Upvotes: 1

Views: 1016

Answers (2)

Marc
Marc

Reputation: 114

You need to specify your own assembly that stops Maven from trying to unpack and then re-pack the contents of the apk file. There's tutorials kicking about on the net for doing this (usually for swfs or zips), but I just did it by specifying something like:

<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>

Save this in its own XML file, then point your POM at this rather than the default assembly descriptor:

<!-- disabled predefined assembly 
<descriptorRefs>
    <descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
-->
<descriptors>
       <descriptor>src/main/assembly/assembly-descriptor.xml</descriptor>
</descriptors>

Upvotes: 1

LoneChaos
LoneChaos

Reputation: 203

I used a different dependency version in my 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>

(You can even check this page for further info : http://selendroid.io/quickStart.html)

Upvotes: 0

Related Questions