支持库不适用于aar

时间:2015-06-16 08:18:58

标签: android maven android-support-library

我的图书馆项目遇到了问题。我在lib的build.gradle中添加了支持依赖项,我在代码中使用了它们。当我构建要在.aar上使用的Maven文件时,支持依赖项被“忽略”,我使用lib的项目看不到它们。

以下是我在lib的gradle收到的警告:

Dependency on a support library, but the SDK installation does not have the "Extras > Android Support Repository" installed. Open the SDK manager and install it.

显然我已经安装了最新版本的支持存储库。

enter image description here

这是lib的gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.android.support:design:22.2.0'
 }
}

在我将lib作为依赖项添加到我的项目中,例如在styles.xml中,我看不到AppCompat主题。

这是应用程序的平台:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "giorgioantonioli.fondesa.spesapp"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile ('com.fondesa:antoniolimaterial:1.0.0@aar'){ //lib
        transitive = true;
    }
}

1 个答案:

答案 0 :(得分:0)

<强>解决

我没有将依赖项添加到lib的.pom文件中:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.fondesa</groupId>
  <artifactId>antoniolimaterial</artifactId>
  <version>1.0.0</version>
  <packaging>aar</packaging>
  <name>Antonioli Material</name>
  <description>Antonioli material library</description>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <developers>
    <developer>
      <id>giorgio.antonioli</id>
      <name>Giorgio Antonioli</name>
    </developer>
  </developers>
  <dependencies>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>appcompat-v7</artifactId>
      <version>22.2.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>support-v4</artifactId>
      <version>22.2.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>recyclerview-v7</artifactId>
      <version>22.2.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>design</artifactId>
      <version>22.2.0</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

之后我将其添加到maven local:

mvn install:install-file -Dfile=pathtoaar\antoniolimaterial-release.aar 
-DgroupId=com.fondesa 
-DartifactId=antoniolimaterial -Dversion=1.0.0 
-Dpackaging=aar 
-DpomFile=pathtopom\antoniolimaterial.pom