gpt4 book ai didi

android - 无法为 Gradle 7.2 版添加 Firebase Crashlytics

转载 作者:行者123 更新时间:2023-12-05 00:11:36 31 4
gpt4 key购买 nike

无法在 Android 中为 Gradle 7.2 添加 Firebase Crashlytics 依赖项/类路径
我应该在哪里写。

classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.0'
我成功地将 Google 服务映射为。
    classpath 'com.google.gms:google-services:4.3.10'    
//to
id "com.google.gms.google-services" version "4.3.10" apply false
如果我映射 Crashlytics 类路径,则会出现以下错误
Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.google.firebase.firebase-crashlytics-gradle', version: '2.9.0', apply: false] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.google.firebase.firebase-crashlytics-gradle:com.google.firebase.firebase-crashlytics-gradle.gradle.plugin:2.9.0')
Searched in the following repositories:
Gradle Central Plugin Repository
Google
MavenRepo
BintrayJCenter
maven(https://jitpack.io)
项目级 Gradle
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.5.30' apply false
id "com.google.gms.google-services" version "4.3.10" apply false
// below line has a problem
id 'com.google.firebase.firebase-crashlytics-gradle' version '2.9.0' apply false

}

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

dependencies {

}
Gradle-wrapper.properties
#Thu May 12 10:12:33 PKT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
设置.gradle
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }

}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }

}
}
rootProject.name = "Video Player"
include ':app'
在发布这个问题之前,我进行了很多搜索,但没有找到有用的东西。

最佳答案

该文档尚未针对新的 Android 项目结构进行更新。
在您的项目级别 build.gradle你需要添加这个:

buildscript {
//other things....
dependencies {
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.0'
}
}

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.20' apply false
id "com.google.gms.google-services" version "4.3.10" apply false
}

task clean(type: Delete) {
delete rootProject.buildDir
}
然后在您的应用级别 build.gradle一开始你需要添加插件
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.firebase.crashlytics'
}
然后在同一个文件中将 Crashlytics 依赖项添加到相应的 block 中:
dependencies {
//... other dependencies
implementation platform('com.google.firebase:firebase-bom:30.1.0')

implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'
}

关于android - 无法为 Gradle 7.2 版添加 Firebase Crashlytics,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72542162/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com