在IntelliJ中构建时未解决的maven android依赖关系

时间:2013-07-01 22:39:58

标签: android intellij-idea viewpagerindicator android-maven-plugin

我正在使用Maven和我的Android项目,以及android-maven-plugin。在我的项目pom.xml文件中,我声明了依赖项,如下所示:

<dependency>
  <groupId>com.viewpagerindicator</groupId>
  <artifactId>library</artifactId>
  <version>2.4.1</version>
  <type>apklib</type>
</dependency>

ViewPagerIndicator依赖于Android 4.1.1.4,它位于Maven Central here上。 但是,我没有用Android 4.1.1.4构建,我建立在4.2.2 r2上,它被声明为:

<dependency>
  <groupId>android</groupId>
  <artifactId>android</artifactId>
  <version>4.2.2_r2</version>
</dependency>

这个工件不在Maven Central上,我正在使用maven-android-sdk-deployer将Android工件推送到我的仓库中。

如果我打开终端并使用maven构建,则没有问题。问题是当我将项目导入IntelliJ并尝试构建时。模块设置(正确)抱怨ViewPagerIndicator apklib模块中Android 4.1.1.4依赖项的路径已损坏。

我检查了我的.m2 / repository文件夹中的Android 4.1.1.4 jar,甚至没有文件夹,这意味着Maven从未下载过它。我猜它与maven-android-plugin在使用Maven构建时的工作方式有关,与IntelliJ构建的方式有关。

我知道我可以抓住jar并自己手动部署它,但我正在寻找更好的解决方案,因此我的团队中的新成员只需要获取源代码而不做任何其他事情来构建项目。我已经为团队设置了Nexus,因此我们不必手动部署第三方jar,并在每个人的计算机上运行sdk部署程序。我希望能够将新的开发人员交给他们,他们可以随便使用它。

2 个答案:

答案 0 :(得分:1)

它对我们有效的方式(与maven-android-sdk-deployer结合使用:

<dependency>
    <groupId>com.viewpagerindicator</groupId>
    <artifactId>library</artifactId>
    <version>${viewpagerindicator.version}</version>
    <type>apklib</type>
    <exclusions>
        <exclusion>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.google.android</groupId>
            <artifactId>support-v4</artifactId>
        </exclusion>
    </exclusions>
</dependency>

我们也在使用IntelliJ构建。通常只需打开pom.xml文件并对“你想将其作为项目打开吗?”说“是”。提示。

答案 1 :(得分:0)

以下是事实:我有maven项目取决于可由maven本身构建的apklib模块,但不是通过intellij。这种情况的解决方案如下:

  1. 将maven项目导入intellij
  2. 打开apklib模块设置并向模块添加显式依赖关系jar(android,support ...)。不要导出此依赖项。您还可以设置提供的范围。
  3. 它对我有用。