在同步gradle时收到以下错误,我检查了与类似问题相关的其他答案并按照他们的答案但仍然得到相同的错误
无法解决:com.google.android.gms:play-services:15.0.1 安装存储库和同步项目在项目的文件显示中显示 结构对话框
当我点击“安装资源库并同步项目”时,我收到以下错误
无法找到依赖项“com.google.android.gms:play-services:15.0.1”
以下是app level gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "mpathak.drivetestapp"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/main/java/Entities', 'src/main/java/mpathak.drivetestapp', 'src/main/java/mpathak.drivetestapp/interfaces', 'src/main/java/interfaces']
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation 'com.google.dagger:dagger:2.6'
annotationProcessor 'com.google.dagger:dagger-compiler:2.6'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.google.android.gms:play-services-drive:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services:15.0.1'
implementation 'com.google.android.gms:play-services-identity:15.0.1'
}
和我的模块gradle(顶级)如下
buildscript {
repositories {
jcenter()
maven {url "https://maven.google.com"}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {url "https://maven.google.com"}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我正在遵循惯例,如
中所述的回购答案 0 :(得分:4)
尝试不使用此implementation "com.google.android.gms:play-services:15.0.1"
但具体的库如
implementation "com.google.android.gms:play-services-gcm:15.0.1"
答案 1 :(得分:3)
我刚刚发现问题是由于jcenter()
库项目build.gradle的顺序导致的。
由于此顺序而发出
allprojects {
repositories {
jcenter()
google()
maven {
url "https://maven.google.com"
}
maven {
url "https://jitpack.io"
}
}}
下面的解决方案顺序
allprojects {
repositories {
maven {
url "https://maven.google.com"
}
maven {
url "https://jitpack.io"
}
jcenter()
google()
}}