错误:找不到参数[com.google.firebase:firebase bom:29.0.1]的方法platform



错误:在org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.类型的对象上找不到参数[com.google.firebase:firebase bom:29.0.1]的方法platform((

尝试升级Gradle版本,但未解决。我正在尝试将该应用程序与firebase连接。

build.gradle(应用程序(

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 31
buildToolsVersion "31.0.0"
defaultConfig {
applicationId "com.example.transportation"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation platform('com.google.firebase:firebase-bom:29.0.1')
implementation 'com.google.firebase:firebase-analytics'
}

build.gradle(项目(

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()

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

项目结构

您需要将firebase的版本降级为

implementation platform('com.google.firebase:firebase-bom:25.12.0')

我在gradle版本上发现了问题,并将其更新为

classpath 'com.android.tools.build:gradle:4.1.3'

运行良好

相关内容

最新更新