【问题标题】:How to handle gradle dependencies that are apparently overwriting each other如何处理显然相互覆盖的 gradle 依赖项
【发布时间】:2019-06-12 14:12:56
【问题描述】:

我正在使用 google firebase(身份验证和云 Firestore)开发应用程序。 在documentation 之后,我应该将以下依赖项添加到我的应用级 build.gradle 文件中,以便访问云 Firestore 数据库

implement 'com.google.firebase:firebase-admin:6.8.1'

但是,这种方法在编译时会产生以下错误:

"注解处理器现在必须显式声明。编译类路径的以下依赖项被发现包含注解处理器。请将它们添加到注解处理器配置中。 - auto-value-1.4.jar (com.google.auto.value:auto-value:1.4) 或者,设置 android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true 以继续以前的行为。请注意,此选项已弃用,将来将被删除。 有关详细信息,请参阅https://developer.android.com/r/tools/annotation-processor-error-message.html。”

我已尝试解决问题,如错误消息中链接网站中所述,将依赖项替换为:

compileOnly 'com.google.firebase:firebase-admin:6.8.1'
annotationProcessor 'com.google.auto.value:auto-value:1.4'

这会消除旧错误,但会导致另一个我无法修复的问题。添加依赖 'com.google.firebase:firebase-admin:6.8.1' 会导致 'com.google.firebase:firebase-auth:17.0.0' 依赖中的某些方法不再起作用。

“错误:找不到符号方法getCurrentUser()
错误:找不到符号方法 signInWithCredential(AuthCredential)"

我的第一个想法是 admin 依赖项包含一些与 auth 相同的类。但是,我真的不太了解这种情况下的 gradle 行为以及如何解决这个问题。

以下是我在 build.gradle 文件中的依赖项

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.facebook.android:facebook-login:[5,6)'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.9'      
    compileOnly 'com.google.firebase:firebase-admin:6.8.1'
    annotationProcessor 'com.google.auto.value:auto-value:1.4'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

【问题讨论】:

    标签: android firebase gradle firebase-admin


    【解决方案1】:

    firebase-admin 依赖项不适用于客户端应用程序。它用于服务器代码。它可能与适用于 Android 的 Firebase 客户端 SDK 冲突。如果你想使用 firebase-admin,你需要一个后端组件到你的应用并在那里调用它。

    【讨论】:

    • 我实际上查错了文档并选择了“Java”而不是“Java Android”。感谢您的快速帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-08
    • 1970-01-01
    • 2014-03-18
    • 2015-11-21
    • 1970-01-01
    相关资源
    最近更新 更多