【问题标题】:Failed to resolve: com.google.android.gms:play-services:15.0.1无法解决:com.google.android.gms:play-services:15.0.1
【发布时间】:2018-11-23 12:35:29
【问题描述】:

在同步 gradle 时出现以下错误,我检查了与类似问题相关的其他答案并按照他们的答案进行操作,但仍然遇到相同的错误

无法解决:com.google.android.gms:play-services:15.0.1 安装存储库并同步项目 在文件中显示 在项目中显示 结构对话框

当我单击“安装存储库并同步项目”时,我收到以下错误

找不到依赖项“com.google.android.gms:play-services:15.0.1”

以下是应用级别的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
}

我遵循约定,如

中所述的 repo

https://developers.google.com/android/guides/setup

【问题讨论】:

    标签: android-studio android-gradle-plugin


    【解决方案1】:

    刚刚发现是jcenter() library project 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()
    }}
    

    【讨论】:

      【解决方案2】:

      尝试不使用此implementation "com.google.android.gms:play-services:15.0.1"

      但是像

      这样的具体库

      implementation "com.google.android.gms:play-services-gcm:15.0.1"

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-04-15
        • 1970-01-01
        • 2016-10-09
        • 2018-01-04
        • 2017-03-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多