我有一个gradle项目,包含模块中的3个build.gradle文件和一个父项。
父级具有以下结构:
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
maven { url 'http://repo.spring.io/milestone' }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
...
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
...
compile fileTree(dir: '../libs', include: '*.jar')
}
}
project(":core") {
apply plugin: "java"
dependencies {
...
compile fileTree(dir: '../libs', include: '*.jar')
}
}
我需要添加以下依赖项 compile' com.google.android.gms:play-services:8.4.0' 我在build.gradle中做了 p>
dependencies {
compile 'com.google.android.gms:play-services:8.4.0'
}
以及android模块文件开头的应用插件
apply plugin: 'com.android.application'
得到了这个:
Error:Cannot change configuration ':android:compile' after it has been resolved.
当我将此依赖项移动到主构建文件的android部分时,它会说:
Error:Could not find com.google.android.gms:play-services:8.4.0.
Searched in the following locations:
file:/C:/Users/user/.m2/repository/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.pom
file:/C:/Users/user/.m2/repository/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.jar
https://repo1.maven.org/maven2/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.pom
https://repo1.maven.org/maven2/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.jar
https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.pom
https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.jar
https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.pom
https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.jar
http://repo.spring.io/milestone/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.pom
http://repo.spring.io/milestone/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.jar
我应该以某种方式将所有依赖项重新组织到模块中相应的build.gradles,还是有另一种方法可以使它工作?