我正在尝试向android maven项目添加各种依赖项,特别是来自build.gradle
文件的项目:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-cast:7.8.0'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:cardview-v7:22.0.0'
compile 'com.android.support:mediarouter-v7:22.0.0'
compile (name:'CastCompanionLibrary-debug', ext:'aar')
compile 'com.github.amlcurran.showcaseview:library:5.0.0'
compile 'com.chrisanderson.mediabrowsercompat:library:0.0.2'
}
我一直在尝试按照here说明,它告诉您设置一个本地存储库:
<repository>
<id>android-support</id>
<name>android-support</name>
<url>file://${env.ANDROID_HOME}/extras/android/m2repository</url>
</repository>
但是我收到了错误:
ArtifactTransferException: Failure to transfer com.android.support:support-v4:jar:23.0.1 from file://${env.ANDROID_HOME}/extras/android/m2repository was cached in the local repository, resolution will not be reattempted until the update interval of android-support has elapsed or updates are forced. Original error: Could not transfer artifact com.android.support:support-v4:jar:23.0.1 from/to android-support (file://${env.ANDROID_HOME}/extras/android/m2repository): Repository path /extras/android/m2repository does not exist, and cannot be created.
这是我的完整pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>xxx</groupId>
<artifactId>xxx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apk</packaging>
<properties>
<!-- at test time this will be overridden with snapshot version -->
<it-plugin.version>4.3.0</it-plugin.version>
</properties>
<repositories>
<repository>
<id>android-support</id>
<name>android-support</name>
<url>file://${env.ANDROID_HOME}/extras/android/m2repository</url>
</repository>
</repositories>
<build>
<sourceDirectory>src</sourceDirectory>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${it-plugin.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>23</platform>
</sdk>
<manifest>
<debuggable>true</debuggable>
</manifest>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
<version>23.0.1</version>
</dependency>
</dependencies>
</project>
答案 0 :(得分:0)
根据错误日志,$ {env.ANDROID_HOME}无法解析,您是否可以尝试对路径进行硬编码并查看错误是否正常。
答案 1 :(得分:0)
我建议改用Maven Android SDK Deployer。它会将文件复制到您的本地Maven仓库或将它们部署到存储库管理器。然后,您可以将它们声明为正常的依赖项,而无需在设置或pom中进一步配置头痛