Flutter Android - com.google.android.gms:play-services-location列出版本失败

4

编译安卓时遇到了这个错误,之前一直能够成功编译,但我不知道出了什么问题。

不过,iOS 的编译正常并且运行良好。我尝试了一些事情,包括检查 gradle 文件是否有 google() 和正确的版本等,但没有任何帮助。 ********************************************************* 失败:构建异常。

WARNING: This version of cloud_firestore will break your Android build if it or its dependencies aren't compatible with AndroidX.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
         See goo.gl/CP92wY for more information on the problem and how to fix it.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
         This warning prints for all Android build failures. The real root cause of the error may be unrelated.
   > Could not resolve com.google.android.gms:play-services-location:15.+.
         *********************************************************
     Required by:
         project :app > project :location
      > Failed to list versions for com.google.android.gms:play-services-location.
         > Could not list versions using M2 pattern 'https://raw.github.com/g123k/ShortcutBadger/master/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
            > Could not get resource 'https://raw.github.com/g123k/ShortcutBadger/master/com/google/android/gms/play-services-location/'.
               > Could not GET 'https://raw.github.com/g123k/ShortcutBadger/master/com/google/android/gms/play-services-location/'. Received status code 400 from server: Bad Request

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s
Finished with error: Gradle task assembleDebug failed with exit code 1

根build.gradle

buildscript {
    repositories {
        google()
        jcenter()
        mavenLocal()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'  // it was 3.3.1 before but didnt compile, 3.2.1 compiles but with firebase errors
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

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

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

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

应用程序 build.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 {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.berkey.berkey"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

//    implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
//    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//
//    android.useAndroidX=true
//    android.enableJetifier=true

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.release

        }
    }
}

flutter {
    source '../..'
}

dependencies {
//    testImplementation 'junit:junit:4.12'
//    androidTestImplementation 'com.android.support.test:runner:1.0.2'
//    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

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

Pubspec.yaml

description: A new Flutter project.
version: 1.2.0+3

environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  algolia: ^0.1.3+2
  firebase_auth: ^0.8.0+3
  cupertino_icons: ^0.1.2
  google_sign_in: ^4.0.1
  cloud_firestore: ^0.9.0+1
  firebase_storage: ^2.0.1
  image_picker: ^0.5.0+3
  location: ^2.0.0
  firebase_messaging: ^3.0.1
  geolocator: ^3.0.0
  firebase_core: ^0.3.0+1
  flutter_launcher_icons: "^0.7.0"
  flutter_linkify: 1.0.3
  url_launcher: ^5.0.1
  permission_handler: '^2.2.0'
  flutter_app_badger: ^1.0.2

Flutter doctor

[✓] Flutter(稳定通道,v1.0.0,在 Mac OS X 10.14.2 18C54 上,语言环境为 en-AU) [✓] Android 工具链 - 用于开发 Android 设备(Android SDK 28.0.3) [!] iOS 工具链 - 用于开发 iOS 设备(Xcode 10.1) ✗ 确认所有连接的设备已在 Xcode 中与此计算机配对。 如果所有设备都已配对,则可能需要更新 libimobiledevice 和 ideviceinstaller。 要使用 Brew 更新,请运行: brew update brew uninstall --ignore-dependencies libimobiledevice brew uninstall --ignore-dependencies usbmuxd brew install --HEAD usbmuxd brew unlink usbmuxd brew link usbmuxd brew install --HEAD libimobiledevice brew install ideviceinstaller [✓] Android Studio(版本 3.3) [✓] 连接的设备(1 可用)


2
你的问题解决了吗?我今天突然遇到了同样的问题。 - CodeGeek
不好意思,如果你找到解决方案,请告诉我。 - Panda Power
还没有解决方案吗? - Daniel Fernandes
真是个麻烦的bug。也许你应该在Github上提交一个问题(issue)。 - Brendan
1个回答

2
有时这可能是因为互联网连接出现问题。请尝试检查一下您的网络连接是否正常。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接