支持库不适用于 aar

Support libraries don't work with aar

我的图书馆项目遇到问题。我在库的 build.gradle 中添加了支持依赖项,并在我的代码中使用了它们。当我构建要在 Maven 上使用的 .aar 文件时,支持依赖项是 "ignored",我在其中使用该库的项目看不到它们。

这是我在库的 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.

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

这里是库的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 主题。

这是应用程序的 gradle:

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;
    }
}

已解决

我没有将依赖项添加到 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 之后:

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