无法解析com.google.android.gms:play-services-location:16.+

伙计们,当我尝试在真实设备上运行我的应用程序但在升级到 1.22.2 后发现该错误时:

 Required by:
     project :app > project :location
  > Failed to list versions for com.google.android.gms:play-services-location.
     > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-location/maven-metadata.xml.
        > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-location/maven-metadata.xml'.
           > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-location/maven-metadata.xml'.
              > Read timed out
  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。

我的 androidappbuild.gradle:

    def localProperties = new Properties()
    def localPropertiesFile = rootProject.file('local.properties')
    if (localPropertiesFile.exists()) {
        localPropertiesFile.withReader('UTF-8') { reader ->
            localProperties.load(reader)
        }
    }
    
    def flutterRoot = localProperties.getProperty('flutter.sdk')
    if (flutterRoot == null) {
        throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
    }
    
    def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
    if (flutterVersionCode == null) {
        flutterVersionCode = '1'
    }
    
    def flutterVersionName = localProperties.getProperty('flutter.versionName')
    if (flutterVersionName == null) {
        flutterVersionName = '1.0'
    }
    
    apply plugin: 'com.android.application'
    apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
    
    def keystoreProperties = new Properties()
    def keystorePropertiesFile = rootProject.file('key.properties')
    if (keystorePropertiesFile.exists()) {
        keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    }
    
    android {
        compileSdkVersion 28
    
        lintOptions {
            disable 'InvalidPackage'
        }
    
        defaultConfig {
            applicationId "io.bujupah.hestia"
            minSdkVersion 17
            targetSdkVersion 28
            versionCode flutterVersionCode.toInteger()
            versionName flutterVersionName
            multiDexEnabled true
        }
    
        signingConfigs {
            release {
                keyAlias keystoreProperties['keyAlias']
                keyPassword keystoreProperties['keyPassword']
                storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
                storePassword keystoreProperties['storePassword']
            }
        }
        buildTypes {
            release {
                signingConfig signingConfigs.release
            }
        }
    }
    
    flutter {
        source '../..'
    }
    
    dependencies {
        implementation 'com.google.android.gms:play-services-auth:16.0.1'
        testImplementation'junit:junit:4.12'
        testImplementation 'org.mockito:mockito-core:2.17.0'
        implementation 'com.android.support:multidex:1.0.3'
    }

我的 androidbuild.gradle:

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

当我运行 flutter --version 时:

Flutter 1.22.4 • 通道稳定 •
https://github.com/flutter/flutter.git框架 • 修订版 1aafb3a8b9(4 个月前) • 2020-11-13 09:59:28 -0800 引擎 • 修订版 2c956a31c0 工具 • Dart 2.10.4

我的位置插件:

 # flutter_map_marker_cluster: any
  flutter_polyline_points: ^0.2.4
  geolocator: ^6.1.1
  geocoding: ^1.0.5
  location: ^3.0.2

回答

解决方法是更新

dependencies {
        com.android.tools.build:gradle:3.6.2
    }

dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
    }

然后将 distributionUrl 更新为

distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip


以上是无法解析com.google.android.gms:play-services-location:16.+的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>