android - Gradle 构建工具找不到 play-services-tasks.aar?为什么?

标签 android maven gradle android-gradle-plugin google-play-services

今天突然,我在 Android Studio 中运行我的应用时遇到了错误。

它是:

Error: Could not find play-services-tasks.aar (com.google.android.gms:play-services-tasks:15.0.1).
Searched in the following locations:
    https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/15.0.1/play-services-tasks-15.0.1.aar

gradle_build_error

我没有更改 gradle 文件中的任何内容,但它突然出现了。我之前的构建在几分钟前成功执行。

为什么找不到 play-services-tasks.aar这是 com.google.android.gms:play-services-tasks:15.0.1

的一部分

采取的步骤:

我检查了我是否在 gradle 文件中包含了所有存储库,并且到目前为止所有存储库都是正确的。

为什么会突然出现这个错误?

我也复制了这个链接https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/15.0.1/play-services-tasks-15.0.1.aar进入浏览器但它工作正常,即我得到“文件下载”对话框。


我的 Gradle 文件

  • 应用层

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 26
        buildToolsVersion "26.0.2"
        defaultConfig {
            applicationId "mekanic24assistantapplication.heba.mekanic24.com.mekanic24assistantapplication"
            minSdkVersion 14
            targetSdkVersion 26
            versionCode 13
            versionName "2.1"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    
    
        dexOptions {
            incremental true
            javaMaxHeapSize "4g"
        }
    
    //    err Android Gradle Duplicate files copied in APK META-INF/license.txt
    
        configurations.all {
    
            resolutionStrategy {
                force 'com.android.support:support-v4:26+'
                force 'com.android.support:support-annotations:26+'
    
    
            }
    
        }
    
    
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES.txt'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/dependencies.txt'
            exclude 'META-INF/LGPL2.1'
        }
    
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        //   compile 'com.android.support:appcompat-v7:26.3.1'
        compile 'com.android.support:appcompat-v7:26+'
        compile 'com.android.support:design:26+'
        compile 'com.android.support:recyclerview-v7:26+'
        compile 'com.android.support:cardview-v7:26+'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        androidTestCompile 'com.android.support:support-annotations:26+'
        testCompile 'junit:junit:4.12'
        //   compile 'com.android.support:appcompat-v7:26.3.1'
        compile 'com.github.markushi:circlebutton:1.1'
        //  compile 'com.android.support:design:26.3.1'
        compile 'com.android.volley:volley:1.0.0'
        compile 'com.google.android.gms:play-services-base:15.0.1'
        compile 'com.android.support:multidex:1.0.1'
        compile 'com.firebase:firebase-client-android:2.5.2'
        compile 'com.google.firebase:firebase-core:15.0.2'
        compile 'com.google.firebase:firebase-messaging:15.0.2'
        compile 'com.google.firebase:firebase-database:15.0.0'
        compile 'com.wang.avi:library:2.1.3'
        compile 'de.hdodenhof:circleimageview:2.2.0'
        compile 'android.lib.recaptcha:reCAPTCHA:2.0.0'
        compile 'com.google.android.gms:play-services-safetynet:15.0.1'
        compile 'com.google.android.gms:play-services-maps:15.0.1'
        compile 'com.google.android.gms:play-services-places:15.0.1'
        compile 'com.google.android.gms:play-services-location:15.0.1'
    
        compile 'com.squareup.picasso:picasso:2.5.2'
        testCompile 'junit:junit:4.12'
        compile 'com.anjlab.android.iab.v3:library:1.0.38'
        compile files('libs/mail.jar')
        compile files('libs/additionnal.jar')
        compile files('libs/activation.jar')
        compile 'com.jakewharton:butterknife:8.8.1'
        annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
        compile 'com.yarolegovich:lovely-dialog:1.1.0'
        compile 'com.mobsandgeeks:android-saripaar:2.0.3'
        compile 'com.github.stfalcon:smsverifycatcher:0.3.1'
        compile 'ch.acra:acra:4.9.0'
        //TODO:  Apache 2.0 license https://github.com/ACRA/acra
        compile 'com.google.android.gms:play-services-ads:15.0.1'
        compile 'com.github.luongvo:GmailBackground:2.0.2'
    
    }
    apply plugin: 'com.google.gms.google-services'
    
  • 项目级别

    buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        maven {
            url "https://dl.bintray.com/android/android-tools"
        }
    
        maven { url "https://jitpack.io" }
        google()
    
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
    
        classpath 'com.google.gms:google-services:3.2.0'
    }
    }
    
    allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        maven {
            url "https://dl.bintray.com/android/android-tools"
        }
    
        maven { url "https://jitpack.io" }
        google()
    
    }
    }
    
    task clean(type: Delete) {
    delete rootProject.buildDir
    }
    

最佳答案

进行以下更改后,错误消失了:

  1. 从 app build.gradle 的存储库中删除了 maven { url 'https://maven.google.com' }
  2. 在顶级 allprojects/repositories 中添加了 maven { url 'https://maven.google.com' } 作为first entry build.gradle
  3. 将所有播放服务和 firebase 依赖项更改为最新版本
  4. 将 google-services 插件的版本更改为 classpath 'com.google.gms:google-services:4.0.1'

关于android - Gradle 构建工具找不到 play-services-tasks.aar?为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50565776/

相关文章:

maven - 服务未注册类 ='interface org.eclipse.tycho.core.shared.ProxyServiceFacade'

java - 使用 Maven 使用 OpenCV 构建 Java 项目

gradle - IntelliJ在gradle中添加子项目依赖项很奇怪

android - Gradle汇编任务后,AndroidManifest.xml编码不可读

java - 无法获取数组列表内的 count 个元素

android - 在 Kotlin 中选择选项卡或滑动页面时如何加载 fragment

android - 在 Android 应用程序的页面转换期间看到的白色背景

java - mvn liquibase :update results in "Failed to resolve the properties file."

java - Gradle 子项目对共享代码的依赖

java - Android 操作系统中 DatePicker 中 setFirstDayOfWeek() 的 Harmony OS 替代方法是什么?