编辑:Android的摇篮构建失败:找不到com.google.android:support-v4:r18
This issue seemed to disappear by its own somehow, possibly due to the new Gradle build system becoming more mature.
我有两个单独的Android项目:
的第一个项目是一个Android Library使用'android-library' Gradle插件,这取决于support-library-v4:r18。从依赖在的build.gradle段:
compile 'com.android.support:support-v4:18.0.0'
支持库是通过Android SDK中经理安装支持Android库牵强,因为解释here。然后,该项目建成并发布运行于本地Maven仓库:gradle uploadArchives
我证实,确实库.aar是那么本地Maven仓库下可用。
该第二项目是使用“机器人”插件摇篮,它引用由第一项目产生的库的行家依赖性 Android应用。下面是片段的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.
当我尝试通过运行建立第二个项目:gradle assemble
我得到以下错误:
Could not find com.google.android:support-v4:r18.
Required by:
com.example:app-project:unspecified > com.example:cool-lib:1.0.0-SNAPSHOT
我检查了.pom文件cool-lib,在我的本地Maven回购文件夹,我看到它有以下依赖性:
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
<version>18.0.0</version>
<scope>compile</scope>
</dependency>
出于某种原因,摇篮是试图让支持库-V4 R18为LIB-项目来自maven中央存储库,而不是从Android支持库。由于support-library-v4的Maven Central的最新版本是r7,因此它失败。
有没有办法迫使摇篮严格从支持Android库获取支持库-V4 R18也被从Maven的中央引用的外部的Android库?
使用两个库,其中一个需要另外一个时,我也看到这个问题。你能解决它吗? – frapontillo
当我的ANDROID_HOME环境变量指向SDK的旧版本时,我有同样的错误 –