18

I've updated to lastest version of ADT Plugin and I faced this issue, solved updating also m2e-android eclipse plugin. Now, I'm able to compile my project through console, but not with eclipse. This is the exception thrown by pom.xml file in eclipse:

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

In previous versions of ADT/m2e-android, I was able to build both console and eclipse without problems.

Does anyone know how to solve this? Maybe my pom.xml is wrong?

Thanks for your time.


Currently using:

  • Eclipse classic 3.7.2 (with Juno the problem persists)
  • ADT 20.0.3
  • m2e-android 0.42
  • android-maven-plugin 3.3.0
  • maven 3.0.4
  • m2e 1.1.0 (included as a dependency in m2e-android 0.42)

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.jelies</groupId>
    <artifactId>my-project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>apk</packaging>

    <dependencies>
        <dependency>
            <groupId>android</groupId>
            <artifactId>android</artifactId>
            <version>4.1_r2</version>
            <scope>provided</scope>
        </dependency>

        <!-- some unrelated dependencies -->

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

    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <sdk>
                        <platform>16</platform>
                    </sdk>
                    <emulator>
                        <avd>avd-4.1</avd>
                    </emulator>
                    <deleteConflictingFiles>true</deleteConflictingFiles>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>eclipse</id>
            <activation>
                <!-- This profile is only activated when m2e.version is present (only 
                    in eclipse) -->
                <property>
                    <name>m2e.version</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>com.google.android</groupId>
                    <artifactId>support-v4</artifactId>
                    <version>r7</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>

EDIT:

Answer is right. Having ABS library project mavenized in my workspace, error is gone! But, another problem appeared: ABS transitive dependencies are added to my project, causing eclipse to be not able to launch the application. This is a known issue you can follow here.

Community
  • 1
  • 1
jelies
  • 9,110
  • 5
  • 50
  • 65

5 Answers5

10

As of Android 0.4.2 you now need to mavenise the Android library projects in your Eclipse workspace for m2e-android to successfully detect them. The POM for ActionBarSherlock can be found here:

https://github.com/JakeWharton/ActionBarSherlock/blob/master/library/pom.xml#

Note: m2e-android is beta software and so changes that might affect functionality can occur between releases.

Ricardo Gladwell
  • 3,770
  • 4
  • 38
  • 59
  • Thanks Ricardo! :) I will try it later. By the way, congrats for m2e-android, it's awesome! – jelies Aug 21 '12 at 09:52
  • Finally added ABS library project to my workspace using maven and error is gone! So, my project structure is [that](http://imgur.com/7VUn4). Why are these "Android dependencies" added there? Robolectric, harmcrest... I haven't problems compiling, but dalvik vm raises a lot of warnings about inner classes when I try to launch. At the end, eclipse crashes too and I think these libraries are the problem :( [Launch exception here](http://pastebin.com/qum40Abn). – jelies Aug 21 '12 at 17:33
  • Uhm... seems like transitive dependencies of ABS are added to my project too... and excluding them does not do the trick. Any suggestion? – jelies Aug 21 '12 at 17:39
  • Ok, I found all the related issues in github. I'm gonna update my question with the information. Thanks for all your effort with m2e-android! – jelies Aug 21 '12 at 18:35
  • 4
    Yeah, apklib support in m2e-android is a work in progress, and we don't yet support the ABS library project. – Ricardo Gladwell Aug 21 '12 at 23:19
  • 4
    Can you please explain what you mean by "mavenise the Android library projects in your Eclipse workspace". That's not really clear to me. Thx. – Flo Aug 31 '12 at 15:52
  • @Flo as in turn into a Maven project, adding a POM. – Ricardo Gladwell Sep 01 '12 at 08:26
  • Mh, ok I did that, by downloading the whole library repo. But my project still shows me the same error message like in the question above. Any suggestions? – Flo Sep 01 '12 at 09:53
  • @Flo do you have the exact Maven coordinates (artifactId, version, etc) in your POM as for the ABS POM checked out in your workspace? – Ricardo Gladwell Sep 02 '12 at 08:06
  • @RicardoGladwell I have a followup question with regards to mavenizing the ActionBarSherlock library. See http://stackoverflow.com/questions/12397444/mavenising-actionbarsherlock-library. Thanks. – dannyroa Sep 12 '12 at 23:31
2

For those who don't know what "MAVENIZED" means it is convert a simple project to be a Maven Project.

In Eclipse, right click in your project, Configure -> Convert to Maven Project

Carlos
  • 1,319
  • 2
  • 17
  • 20
1

you can include the actionbarsherlock dependency as jar file only when using eclipse via profiles

<profile>
  <id>m2e</id>
  <activation>
    <property><name>m2e.version</name></property>
   </activation>
   <dependencies>
    <dependency>
      <groupId>com.actionbarsherlock</groupId>
      <artifactId>actionbarsherlock</artifactId>
      <version>${abs.version}</version>
      <type>jar</type>
    </dependency>
  </dependencies>
</profile> 

and don't need to include the entire actionbarsherlock as project in eclipse

ffgiraldez
  • 722
  • 7
  • 16
  • 1
    This won't allow one to use ressources from ABS, like a style with an SBS parent (parent="Theme.Sherlock.Light.DarkActionBar") – blacelle Nov 01 '13 at 19:59
1

I've wrote detailed tutorial about mvn + eclipse + action bar sherlock integration http://v.zasadnyy.com/blog/abs-maven-eclipse-integration/

Hope it will be helpful.

zasadnyy
  • 2,107
  • 2
  • 19
  • 26
1

Add this to your parent pom.xml file as a dependency:

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

And the following lines to your project pom.xml:

<dependency>
    <groupId>com.actionbarsherlock</groupId>
    <artifactId>actionbarsherlock</artifactId>
    <version>4.2.0</version>
</dependency>
josomers
  • 11
  • 3
  • Yes, you're right, but only since 4.2.0. This does not work with 4.1.0. – jelies Feb 13 '13 at 13:23
  • True, this is because ABS is available from 4.2.0 on Maven Central. [link](http://search.maven.org/#artifactdetails%7Ccom.actionbarsherlock%7Cactionbarsherlock%7C4.2.0%7Capklib) – josomers Feb 13 '13 at 13:43
  • In fact, ABS was available at maven central since [4.0.0](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.actionbarsherlock%22%20AND%20a%3A%22library%22), but the dependencies were not being resolved correctly with 4.1.0 and your approach didn't work :( – jelies Feb 13 '13 at 20:56
  • I just added the version number to the parent dependency. This approach worked for me... Make sure you restart eclipse and 'update project' – josomers Feb 14 '13 at 09:53
  • No, with 4.2.0 ;) But I can't access the theme's file for ABS now. I'll let you know when it works. – josomers Feb 14 '13 at 12:21
  • I found that the android maven plugin for eclipse still not support apklibs 100%. I'm now working with IntelliJ, imported the dependency as Jake Warthon documented and it works like a charm. Succes! – josomers Feb 14 '13 at 16:14