Search code examples
androideclipseandroid-maven-plugin

POM error when using ActionbarSherlock with Eclipse and Maven


I'm starting a project which I want to compile with both Eclipse and Maven. On command line everything works fine and if I remove Maven nature the project runs OK in Eclipse. However with Maven enabled I get this error in first line of the POM

dependency=[com.actionbarsherlock:actionbarsherlock:apklib:4.2.0:compile] 
    not found in workspace

Here's my complete POM

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.foo.bar</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>test</name>
    <properties>
        <java.version>1.6</java.version>
        <platform.version> 4.1.1.4</platform.version>
        <android.platform>16</android.platform>
        <android-support.version>r7</android-support.version>
        <abs-version>4.2.0</abs-version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${platform.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>support-v4</artifactId>
            <version>${android-support.version}</version>
        </dependency>
        <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>actionbarsherlock</artifactId>
            <version>${abs-version}</version>
            <type>apklib</type>
        </dependency>
    </dependencies>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.5.0</version>
                <configuration>
                    <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
                    <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                    <resourceDirectory>${project.basedir}/res</resourceDirectory>
                    <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
                    <sdk>
                        <platform>${android.platform}</platform>
                    </sdk>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

I also noticed that there's no link to ABS from Eclipse->Properties->Android->Library

What am I missing in this setup?


Solution

  • Like you I compile with Maven and Eclipse, however I do not use the maven nature as it was too painful when I tried to use it.

    Given that your error mentions ABS and that is a APKLIB which is kinda "faked" by Maven you might want ensure that this APKLIB is installed into your local maven repo. I dont believe that the maven nature supports workspace resolution but I could be wrong in this.

    If that doesnt work you can always follow my example and just set eclipse up they default way which would mean turning off the maven nature and linking using Eclipse->Properties->Android->Library as you mentioned