Добавление зависимостей, таких как support-v4 и appcompat-v7

Я пытаюсь добавить различные зависимости в проект 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'

}

Я пытался следовать здесь инструкциям, которые говорят вам установить локальный репозиторий с:

<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.

Вот мой полный пом:

<?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>

2 ответа

В соответствии с журналами ошибок ${env.ANDROID_HOME} не разрешается, вы можете попытаться жестко закодировать путь и посмотреть, пройдут ли ошибки.

Вместо этого я предлагаю использовать Maven Android SDK Deployer. Он скопирует файлы в локальное хранилище Maven или развернет их в диспетчере хранилища. Тогда вы можете просто объявить их как обычные зависимости без дополнительных настроек головной боли в настройках или пом

Другие вопросы по тегам