Android的摇篮构建失败:找不到com.google.android:support-v4:r18 [英] Android Gradle build fails: Could not find com.google.android:support-v4:r18

查看:1807
本文介绍了Android的摇篮构建失败:找不到com.google.android:support-v4:r18的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:

  

此问题似乎由它自己消失在某种程度上,这可能是由于新的摇篮构建系统变得更加成熟。

我有两个单独的Andr​​oid项目:

第1项目使用的的Andr​​oid库的插件摇篮,这取决于在支持库-V4一个Android库:R18 。从片段的依赖的中的 build.gradle 的:

 编译com.android.support:support-v4:18.0.0
 

支持库距离的 Android的支持库的通过的 Android的SDK管理器的安装牵强,因为解释的此处。该项目然后建立并发布运行到Maven本地存储库:摇篮uploadArchives

我核实,确实库 .aar 然后可在本地Maven仓库下。

第2项目是使用一个Android应用程序的机器人的插件摇篮,它引用的第一个项目产生的库在 Maven的依赖。下面是一个片段的 build.gradle 的:

 库{
    mavenLocal()
    mavenCentral()
}
依赖{
    编译com.android.support:support-v4:18.0.0
    编译com.example:酷lib目录下:1.0.0-快照
}
 

  

注意:这两个项目是完全相互分离。意思是,   他们是不一样的根项目的子项目。

当我试图通过运行建立第二个项目:摇篮组装

我收到以下错误:

 找不到com.google.android:support-v4:r18。
要求:
    com.example:应用程序项目:未指定> com.example:酷lib目录下:1.0.0-快照
 

我查了 .pom 文件中的冷的lib 的,在我的本地Maven回购文件夹,我看到它有以下依赖性:

 <依赖>
  <的groupId> com.android.support< /的groupId>
  < artifactId的>支持-V4< / artifactId的>
  <版> 18.0.0< /版本>
  <范围>编译< /范围>
< /依赖性>
 

由于某些原因,摇篮正在试图获得的支持库-V4 R18 作为的从Maven的中央存储库,而不是LIB-项目的从 Android的支持库的得到它。它失败,因为最新版本的Maven的中央的支持库-V4 的是 R7

有没有办法强制摇篮严格获取的支持库-V4 R18 Android的支持库的也为外部的Andr​​oid库这是从中央Maven的参考?

解决方案

您需要从SDK管理器安装 Android的支持库。之后,摇篮就能够从 $解决支持库{SDK_HOME} \演员\机器人\ m2repository \

EDIT:

This issue seemed to disappear by its own somehow, possibly due to the new Gradle build system becoming more mature.

I have two separate Android projects:

The 1st project is an Android Library using 'android-library' plugin for Gradle, which depends on the support-library-v4:r18. Snippet from dependencies in build.gradle:

compile 'com.android.support:support-v4:18.0.0'

The support library is fetched from Android Support Repository installed via Android SDK Manager as explained here. This project is then built and published to maven local repository by running: gradle uploadArchives

I verified and indeed the library .aar is then available under the local maven repository.

The 2nd project is an Android app using 'android' plugin for Gradle, which references the maven dependency of the library produced by the first project. Here is a snippet from build.gradle:

repositories {
    mavenLocal()
    mavenCentral()
}
dependencies {
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.example:cool-lib:1.0.0-SNAPSHOT'
}

NOTE: The two projects are completely separated from another. Meaning that, they are NOT subprojects of the same root project.

When I try to build the 2nd project by running: gradle assemble

I get the following error:

Could not find com.google.android:support-v4:r18.
Required by:
    com.example:app-project:unspecified > com.example:cool-lib:1.0.0-SNAPSHOT

I checked the .pom file of cool-lib, under my local maven repo folder and I saw that it has the following dependency:

<dependency>
  <groupId>com.android.support</groupId>
  <artifactId>support-v4</artifactId>
  <version>18.0.0</version>
  <scope>compile</scope>
</dependency>

For some reason, Gradle is trying to get the support library-v4 r18 for the lib-project from maven central repository instead of getting it from Android Support Repository. It fails since the latest version in Maven Central of the support-library-v4 is r7.

Is there a way to force Gradle to strictly fetch the support-library-v4 r18 from Android Support Repository also for external Android libraries which are referenced from Maven Central?

解决方案

You need to install Android Support Repository from SDK manager. After that Gradle will be able to resolve support libraries from ${SDK_HOME}\extras\android\m2repository\.

这篇关于Android的摇篮构建失败:找不到com.google.android:support-v4:r18的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆