java - 将 Firebase Crashlytics 添加到 Android 时出现“重复类 javax.inject.*”构建错误
问题描述
我正在尝试将Firebase Crashlytics添加到我的项目中。我收到以下错误。
Duplicate class javax.inject.Inject found in modules javax.inject-1.jar (javax.inject:javax.inject:1) and jetified-roboguice-3.0.1.jar (org.roboguice:roboguice:3.0.1)
Duplicate class javax.inject.Named found in modules javax.inject-1.jar (javax.inject:javax.inject:1) and jetified-roboguice-3.0.1.jar (org.roboguice:roboguice:3.0.1)
Duplicate class javax.inject.Provider found in modules javax.inject-1.jar (javax.inject:javax.inject:1) and jetified-roboguice-3.0.1.jar (org.roboguice:roboguice:3.0.1)
Duplicate class javax.inject.Qualifier found in modules javax.inject-1.jar (javax.inject:javax.inject:1) and jetified-roboguice-3.0.1.jar (org.roboguice:roboguice:3.0.1)
Duplicate class javax.inject.Scope found in modules javax.inject-1.jar (javax.inject:javax.inject:1) and jetified-roboguice-3.0.1.jar (org.roboguice:roboguice:3.0.1)
Duplicate class javax.inject.Singleton found in modules javax.inject-1.jar (javax.inject:javax.inject:1) and jetified-roboguice-3.0.1.jar (org.roboguice:roboguice:3.0.1)
Go to the documentation to learn how to Fix dependency resolution errors.
项目级别build.gradle
:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用级别build.gradle
:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "package.name"
minSdkVersion 21
targetSdkVersion 29
versionCode 26
versionName "1.4.1"
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds true
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
project.tasks.withType(JavaCompile) { task ->
options.compilerArgs << "-AguiceAnnotationDatabasePackageName=package"
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
testImplementation project(':module1')
testImplementation 'org.mockito:mockito-core:1.+'
testImplementation('org.robolectric:robolectric:3.1-rc1') {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
implementation project(':module1')
implementation project(':module2')
implementation project(':roboguicehelper')
compileOnly 'org.roboguice:roboblender:3.+'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'org.roboguice:roboguice:3.+'
implementation 'com.google.android.material:material:1.0.0'
//noinspection GradleCompatible
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation project(':module4')
implementation platform('com.google.firebase:firebase-bom:26.6.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics'
}
如果我删除它->implementation 'com.google.firebase:firebase-crashlytics'
项目构建并运行良好。但我需要添加 Crashlytics。
Gradle 版本是gradle-5.6.4
有什么建议么?
解决方案
推荐阅读
- python - ModuleNotFoundError 与 Apache 服务器上的 wsgi
- node.js - 将 Sequelize 原始查询绑定到模型
- php - 在管理区域中的 WooCommerce 下方添加自定义链接作为子菜单
- java - 将参数传递给 jpa 转换器
- javascript - Discord.js 的角色反应
- python-3.x - Python如何创建一个按钮矩阵并将其放在我的一个框架内
- python - sqlalchemy 中自我引用的一对多父子模型上的 hybrid_property "is_parent"
- scala - 过滤导致 Spark 中数据类型解析问题的行
- authentication - 收到登录消息时,QuickFix 启动器应用程序注销
- x86 - 英特尔架构中的锁语义