Flutter 构建错误:“无法解析 com.google.android.gms:play-services-ads-base:[19.7.0]。”
Posted
技术标签:
【中文标题】Flutter 构建错误:“无法解析 com.google.android.gms:play-services-ads-base:[19.7.0]。”【英文标题】:Flutter Build Error: "Could not resolve com.google.android.gms:play-services-ads-base:[19.7.0]." 【发布时间】:2022-01-15 18:44:14 【问题描述】:最近我在 Flutter 上收到以下构建错误:
无法确定任务 ':app:processDebugResources' 的依赖关系。
无法解析配置“:app:debugRuntimeClasspath”的所有任务依赖项。 无法解析 com.google.android.gms:play-services-ads-base:[19.7.0]。 要求: 项目:app > 项目:google_mobile_ads > com.google.android.gms:play-services-ads:19.7.0 项目:app > 项目:google_mobile_ads > com.google.android.gms:play-services-ads:19.7.0 > com.google.android.gms:play-services-ads-lite:19.7.0 项目:app > 项目:google_mobile_ads > com.google.android.gms:play-services-ads:19.7.0 > com.google.android.gms:play-services-gass:19.7.0 > 无法列出 com.google.android.gms:play-services-ads-base 的版本。 > 无法从 https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-base/maven-metadata.xml 加载 Maven 元数据。 > 无法获取资源“https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-base/maven-metadata.xml”。 > 无法获取“https://google.bintray.com/exoplayer/com/google/android/gms/play-services-ads-base/maven-metadata.xml”。从服务器收到状态码 502:Bad Gateway
我相信这是由于 bintray 贬值所致。这是我的 android/build.gradle
buildscript
ext.kotlin_version = '1.3.50'
repositories
mavenCentral()
google()
// jcenter()
// maven
// url 'https://dl.bintray.com/android/android-tools'
//
dependencies
classpath 'com.android.tools.build:gradle:3.5.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
allprojects
repositories
mavenCentral()
google()
//
// jcenter()
rootProject.buildDir = '../build'
subprojects
project.buildDir = "$rootProject.buildDir/$project.name"
subprojects
project.evaluationDependsOn(':app')
task clean(type: Delete)
delete rootProject.buildDir
我已将 jcenter 替换为 mavenCentral,清除缓存并运行 flutter clean 但我仍然收到相同的错误
这是我的应用级 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 plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android
compileSdkVersion 29 // used to be 28
sourceSets
main.java.srcDirs += 'src/main/kotlin'
lintOptions
disable 'InvalidPackage'
defaultConfig
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.eventr_app_2021"
minSdkVersion 19
targetSdkVersion 29
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
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.debug
flutter
source '../..'
dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-analytics:17.5.0'
implementation 'com.google.firebase:firebase-messaging:21.0.1'
implementation 'com.google.android.gms:play-services-basement:18.0.0' //used to be 17.4.0
【问题讨论】:
【参考方案1】:apply plugin: 'com.google.gms.google-services'
// Work around for onesignal-gradle-plugin compatibility
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck =
true
【讨论】:
以上是关于Flutter 构建错误:“无法解析 com.google.android.gms:play-services-ads-base:[19.7.0]。”的主要内容,如果未能解决你的问题,请参考以下文章
全新 Flutter 和 Dart 安装时的构建错误(导入错误)