I am trying to add Firebase Crashlytics to my project. I am getting the below error.
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.
Project level 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
}
App level 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'
}
If I remove this -> implementation 'com.google.firebase:firebase-crashlytics'
the project builds and runs fine. But I need to add Crashlytics.
Gradle version is gradle-5.6.4
Any Suggestions?
From the below image, we can see that the roboguice
library already has the java.inject
library inside it. And with that, Firebase Crashlytics adds java.inject:java.inject:1@jar
to the libraries which caused the error.
Changing the below line in App level build.gradle
from
implementation 'com.google.firebase:firebase-crashlytics'
to
implementation ('com.google.firebase:firebase-crashlytics') {
exclude module: "javax.inject"
}
fixed the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With