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

问题描述 投票:0回答:1

错误:在 org.gradle.api.internal.artifacts.dsl.dependency.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
}

Project Structure

firebase android-studio build.gradle platform
1个回答
0
投票

您需要将firebase版本降级到

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

我发现了gradle版本的问题,将其更新为

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

效果很好

© www.soinside.com 2019 - 2024. All rights reserved.