java 无法解析网站,谷歌,安卓,gms:播放服务位置:16,+

fxnxkyjh  于 2022-12-21  发布在  Java
关注(0)|答案(7)|浏览(166)

伙计们,当我试图在真实的设备上运行我的应用程序,但我发现升级到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运行以获取完整的见解。

我的安卓系统\app\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 {
            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'
    }

我的安卓系统\build.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时--版本:
Flutter1.22.4 ·通道稳定·https://github.com/flutter/flutter.git框架·修订版1aafb 3a 8b 9(4个月前)· 2020年11月13日09:59:28 - 0800引擎·修订版2c 956 a31 c 0工具· 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
gz5pxeao

gz5pxeao1#

解决方案已更新

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

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

则更新分发URL为

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

n3schb8v2#

以下更改适合我

//Project level build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.+'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.10'
    }
}

//App level build.gradle

configurations.all {
    resolutionStrategy {
        force 'com.google.android.gms:play-services-location:16.0.0'
    }
}
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.android.gms:play-services-location:16.0.0'//add this line 
}
tnkciper

tnkciper3#

Jcenter()替换为mavenCentral()对我很有效。

repositories {
    google()
    mavenCentral()  // Add this
    jcenter()    // remove this   
}

对于REACT-NATIVE用户:在你的android文件夹中,在...\android\build.gradle文件中做这个修改。

ne5o7dgx

ne5o7dgx4#

对于那些还没有用AzizDev的解决方案解决问题的人,试试这个解决方案:
也许你的一些依赖是过时的..所以,运行这个命令在终端升级他们,然后运行这项目

flutter pub upgrade --major-versions
7kqas0il

7kqas0il5#

该网站正在进行维护,寻找jcenter()替代或等待,直到他们解决这个问题。

relj7zay

relj7zay6#

转到你的.pub-cache/hosted/pub.dartlang.org/转到你的插件,然后转到android文件夹/更改你的com.google.android.gms:play-services-location:16.+的版本到特定的版本.然后它会完美地工作

注意:您的.pub/cache文件夹路径在windows中应该不同,如果.pub-cache文件夹是隐藏的,您还需要取消隐藏它

w8f9ii69

w8f9ii697#

只需检查flutter项目中的gradle版本,如下所示:
/安卓/构建版本.gradle:

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

/安卓/升级包/ Package 器/gradle-wrapper.properties:

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

相关问题