M Rajoy
M Rajoy

Reputation: 4104

Maven + RoboGuice + ActionBarSherlock + RoboGuice-Sherlock

I am trying to create an Android base project using android-quickstart archetype, and adding RoboGuice, ActionBarSherlock dependencies, plus RoboGuice-Sherlock to combine the two.

This is my pom.xml:

   <?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.myapp</groupId>
    <artifactId>BaseApp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>BaseApp</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <platform.version> 4.1.1.4
        </platform.version>
        <android.plugin.version>3.6.0</android.plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${platform.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.roboguice</groupId>
            <artifactId>roboguice</artifactId>
            <version>2.0</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <version>1.3.9</version>
        </dependency>

        <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>actionbarsherlock</artifactId>
            <version>4.4.0</version>
            <type>apklib</type>
        </dependency>


        <dependency>
            <groupId>com.github.rtyley</groupId>
            <artifactId>roboguice-sherlock</artifactId>
            <version>1.5</version>
        </dependency>

    </dependencies>



    <build>
        <finalName>${project.artifactId}</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>${android.plugin.version}</version>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <sdk>
                        <platform>16</platform>
                    </sdk>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

But m2eclipse wont work with this Pom.xml, as it is unable to find the apklib dependency. Speficically I am getting the following message under "Problems" tab in Eclipse:

dependency=[com.actionbarsherlock:actionbarsherlock:apklib:4.4.0:compile] not found in workspace    pom.xml /BaseApp    line 1  me.gladwell.eclipse.m2e.android.markers.dependency.apklib

I have tried removing the <type>apklib</type> line but then my ABS resources (namely the required Themes) are not imported into the project.

I've read in several questions that the apklib type only works on command line, and that if I want to stick to the IDE I need to import ABS manually as a library. I did, but then RoboGuice crashes because the project becomes a library project and, apparently, resource ids are not final anymore in library projects. (The compile-time error I get is "The value for annotation attribute InjectView.value must be a constant expression"). For reference, this is my only Activity:

public class HelloAndroidActivity extends RoboSherlockActivity {

     @InjectView(R.id.helloworld) TextView textView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView.setText("Roboguice  says Hello World");
    }

}

IS there any proper way to create a base project with these three elements using maven and Eclipse?

Upvotes: 4

Views: 1124

Answers (1)

M Rajoy
M Rajoy

Reputation: 4104

Turns out I accidentally clicked the "Is Library" checkbox on Project Properties. Now it works with ABS manually imported as a library.

It is a pity though not being able to use Maven directly :(

Upvotes: 1

Related Questions