gpt4 book ai didi

android - 添加 firebase-messaging 时出现错误 :Execution failed for task ':app:processDebugGoogleServices' .

转载 作者:行者123 更新时间:2023-12-03 05:55:20 24 4
gpt4 key购买 nike

当我添加以下行时:在文件 build.gradle 中编译 'com.google.firebase:firebase-messaging:10.0.1' 并立即在 AndroidStudio 中单击同步:

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.0.1.



我删除了行 apply plugin: 'com.google.gms.google-services' 然后错误消失了。但是firebase-auth失败:Caused by: java.lang.IllegalStateException: Default FirebaseApp没有在这个进程br.ufrn.imd.sgr中初始化。确保首先调用 FirebaseApp.initializeApp(Context)。

请帮帮我。

build.gradle(项目)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

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

build.gradle(模块应用程序):
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "package.exemplo"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'

compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-auth:11.0.2'
compile 'com.google.code.gson:gson:2.6.2'
compile project (':volley')
}


apply plugin: 'com.google.gms.google-services'

最佳答案

在这里交易:您添加了太旧的依赖项。
您的 Firebase 身份验证依赖版本是 11.0.2 :

compile 'com.google.firebase:firebase-auth:11.0.2'

并且您添加了一个版本为 10.0.1 的 Firebase 依赖项。 :
compile 'com.google.firebase:firebase-messaging:10.0.1'

所以存在依赖版本冲突。这就是您尝试同步时出现 Gradle 构建错误的原因。

要解决这个问题,只需让您的 firebase-messaging依赖版本到最新版本并重新应用 Google Services Gradle 插件:
dependencies {
...

compile 'com.google.firebase:firebase-auth:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'

...
}

apply plugin: 'com.google.gms.google-services'

希望这可以帮助。

关于android - 添加 firebase-messaging 时出现错误 :Execution failed for task ':app:processDebugGoogleServices' .,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45202291/

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