2015-06-16 246 views
2

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

这是我收到的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' 
} 
} 

在我的项目中,我在styles.xml添加的lib的依赖,例如,我看不到程序兼容性主题。

这里是应用程序的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:[email protected]'){ //lib 
     transitive = true; 
    } 
} 
+0

@HugoGresse现在我不能尝试它,但是当我要做的时候,我会写回应 –

+0

@HugoGresse,但没有解决问题 –

+0

我试过你是代码,它的工作原理应该如此。一定要更新SDK(我知道你说你有,但...)https://www.dropbox.com/s/gcz6rxfjgxf3l14/Capture%20d%27%C3%A9cran%202015-06-16%2011.33。 12.png?dl = 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后:

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