3

I'm working on a project using RoboGuice with Eclipse ADT, m2e and android-maven-plugin.

I'm using RoboListFragment class which depends on android.support.v4.app.ListFragment, for this reason I've added the following dependency to pom.xml

<dependency>
    <groupId>com.google.android</groupId>
    <artifactId>support-v4</artifactId>
    <version>r7</version>
    <scope>provided</scope>
</dependency>

Nevertheless eclipse does not add that library to build path. When I build my project from command line everything is ok, but in eclipse I get this error message:

The type android.support.v4.app.Fragment cannot be resolved. It is indirectly referenced from required .class files

The only workaround I found is adding it to the build path as an external jar, but then .classpath refers to my own home directory.

1 Answers1

4

Try to remove

<scope>provided</scope>

In Maven, this means support-v4 will be in the classpath (see http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope)

pralonga
  • 106
  • 3
  • Removing provided works. Thank you! (But I'm not sure it's a clean way) – Davide Bellettini Aug 21 '13 at 16:36
  • `provided` means the application is expecting the container (or other classpath provider) to include that dependency for you. Thus Maven (and Eclipse) doesn't download it separately. A typical use for `provided` scope is for things like Java EE libraries that are provided by Tomcat, WebLogic or other application server. – user944849 Aug 21 '13 at 16:55
  • Maven downloads provided artifacts. These artifacts will only be used for compilation, and will not be included in the final package, as they are _provided_ by the framework (like Servlet API for Tomcat as you said). @dbellettini if this solved your problem, you should accept the answer. It makes things easier to read. – pralonga Aug 22 '13 at 08:14
  • Seems like that Eclipse won't see any provided dependency whose groupId begins with com.google.android despite Maven builds correctly – Davide Bellettini Sep 20 '13 at 10:05