问题描述
我正在尝试在我的应用中实现Firebase,但是在查找Google服务时遇到了问题:
FAILURE: Build Failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.google.gms:google-servies:4.3.4.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/google/gms/google-servies/4.3.4/google-servies-4.3.4.pom
- https://dl.google.com/dl/android/maven2/com/google/gms/google-servies/4.3.4/google-servies-4.3.4.jar
- https://jcenter.bintray.com/com/google/gms/google-servies/4.3.4/google-servies-4.3.4.pom
- https://jcenter.bintray.com/com/google/gms/google-servies/4.3.4/google-servies-4.3.4.jar
required by:
project :
* 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 3s
Exception: Gradle task assembleDebug Failed with exit code 1
我发现了类似的问题,但是问题主要是google-services或build:gradle的版本。我尝试了其他版本(google-services:4.3.4 / 4.3.3 / 4.3.2 / 4.3.1 / 4.3.0 / 4.2.0),但是它们都不起作用。
这是项目级别的build.gradle:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.gms:google-servies:4.3.4"
}
}
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
}
这是应用程序级别的build.gradle:
def localProperties = 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 Exception("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 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.testapp.testapp"
minSdkVersion 17
targetSdkVersion 28
versionCode FlutterVersionCode.toInteger()
versionName FlutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}
Flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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'
}
我希望我已添加了所有必要的内容。提前致谢!
解决方法
您有错字。工件的名称为“ com.google.gms:google-services:4.3.4”。您在“服务”中缺少“ c”。