找不到play-services-tasks-license.aar(com.google.android.gms:play-services-tasks-license:11.8.0)

时间:2018-10-25 11:06:15

标签: javascript android react-native android-gradle

error imagee

尽管我进行了研究,但仍无法找出问题所在。请帮助我。我在哪里出错? 我分享了以下所有信息。我尝试了所有方法,但无法解决问题。

build.gradle文件:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
def googlePlayServicesVersion = '11.8.0'

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

def versionOverrides = [
        "com.facebook.android:facebook-android-sdk": "4.22.1",
]

project(':react-native-fbsdk') {
    configurations.all {
        resolutionStrategy {
            force 'com.facebook.android:facebook-android-sdk:4.22.1'
        }
    }
}

allprojects {
    repositories {
        // Add jitpack repository (added by tipsi-stripe)
        maven { url "https://jitpack.io" }
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    configurations.all {
            resolutionStrategy {
                    // react-native-admob
                    force "com.google.android.gms:play-services-ads:$googlePlayServicesVersion"

                    // react-native-onesignal
                    force "com.google.android.gms:play-services-gcm:$googlePlayServicesVersion"
                    force "com.google.android.gms:play-services-analytics:$googlePlayServicesVersion"
                    force "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
                    force 'com.facebook.android:facebook-android-sdk:4.22.1'
             }

            resolutionStrategy.eachDependency { DependencyResolveDetails details ->

                def overrideVersion = versionOverrides[details.requested.group + ":" + details.requested.name]

                if (overrideVersion != null && details.requested.version != overrideVersion) {
                    println("********************************************************")
                    println("Overriding dependency ${details.requested.group}:${details.requested.name} version ${details.requested.version} --> $overrideVersion")
                    details.useVersion overrideVersion
                    println("********************************************************")
                }
            }
        }
}

subprojects {
    afterEvaluate {
        project -> if (project.hasProperty("android")) {
            android {
                compileSdkVersion 26
                buildToolsVersion '26.0.2'
            }
        }
    }
}

本机运行Android错误:

> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-onesignal'.
      > Could not find play-services-tasks-license.aar (com.google.android.gms:play-services-tasks-license:11.8.0).
        Searched in the following locations:
            https://jcenter.bintray.com/com/google/android/gms/play-services-tasks-license/11.8.0/play-services-tasks-license-11.8.0.aar

2 个答案:

答案 0 :(得分:9)

JCenter不提供https://jcenter.bintray.com/com/google/android/gms/play-services-tasks-license/11.8.0/play-services-tasks-license-11.8.0.aar。这样做:

maven { https://maven.google.com/ } 

maven { url "https://maven.google.com" }交换jcenter()并重试。

build.gradle

allprojects {
    repositories {
        mavenLocal()
        maven {
            url "https://maven.google.com"
        }
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.31.0'
                force 'com.google.android.gms:play-services-base:11.8.0'
                force 'com.google.android.gms:play-services-maps:11.8.0'
                force 'com.google.android.gms:play-services-gcm:11.8.0'
                force 'com.google.android.gms:play-services-location:11.8.0'
            }
        }
    }
}

答案 1 :(得分:0)

我遇到了同样的问题,我只是注释或删除了build.gradle文件的最后一个链接。

我从build.gradle文件的末尾删除了这一行

apply plugin: 'com.google.gms.google-services'  

dependencies {
    compile 'com.android.support:support-v4:24.0.0'
    compile 'com.google.android.gms:play-services-ads:11.8.0'
    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'  //**Comment or Remove this Line**