0

When I configured my apklib I included:

    <dependency>
        <groupId>android</groupId>
        <artifactId>android</artifactId>
        <version>4.0_r3</version>
        <scope>provided</scope>
    </dependency>

in the dependencies list. If I don't do that it won't recognize the source code in the editor and won't compile. However, my question is, does the Android SDK then get included into the project that uses the apklib? It seems so. However, why would it be so? I thought which SDK to use should be only decided by the project that uses the apklib rather then the apklib itself(?). I don't want to use an apklib that for example use api-level 19 when I use api-level 14 in my main project.

In short: Does an SDK dependency in the apklib pom get included into the main project (using Maven)?

JohnyTex
  • 3,323
  • 5
  • 29
  • 52

1 Answers1

0

I got it.

One should use scope=provided for the dependency.

Then, Maven assumes that the container project supplies the classes, and so the SDK classes don't get imported together with the apklib.

ahmed_khan_89
  • 2,755
  • 26
  • 49
JohnyTex
  • 3,323
  • 5
  • 29
  • 52
  • you mean that if you put `4.0_r3` and you target `level 14` , the compiler will not compile all the classes of the sdk? can you add a link or reference, or anything that made you have this conclusion? – ahmed_khan_89 Jun 05 '14 at 09:21
  • From Maven docs: Scope=provided: This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive. – JohnyTex Jun 05 '14 at 09:23
  • What I believe is that with scope=provided, the apklib itself will compile by itself, but when I import it (the apklib) from another main project as a dependency, then the SDK classes to the apklib will be supplied from that main project instead of from the apklib. This is what I believe, but I am not 100% sure. It seems to be like that when I have used it. If you find out otherwise, please comment so that I can change my answer. – JohnyTex Jun 05 '14 at 09:27