I am encounter a problem when I try to build the Android app and it appear error. The error appear after I add the last line in Gradle Build file (the natural language library). Below is my gradle build file code
plugins {
id 'com.android.application'
id 'com.google.secrets_gradle_plugin' version '0.5'
id 'com.google.gms.google-services'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.myvolunteer"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-firestore:23.0.3'
implementation 'com.firebaseui:firebase-ui-firestore:8.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.firebase:firebase-database:20.0.2'
implementation 'com.google.firebase:firebase-storage:20.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Import the BoM for the Firebase platform
// Declare the dependencies for the Firebase Cloud Messaging and Analytics libraries
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-messaging:22.0.0'
implementation 'com.google.firebase:firebase-analytics:19.0.1'
//Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
//Circle Image View
implementation 'de.hdodenhof:circleimageview:3.1.0'
//Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
implementation 'com.karumi:dexter:6.2.3'
implementation 'com.google.android.gms:play-services-location:18.0.0'
//Cloud-lang,but it causes duplicate classes occur.
implementation 'com.google.cloud:google-cloud-language:2.1.2'
}
Some of the error that I get when try to build the project in Android Studio (it's too much I can't put all of them here)
Duplicate class com.google.api.Advice found in modules proto-google-common-protos-2.5.0 (com.google.api.grpc:proto-google-common-protos:2.5.0) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0)
Duplicate class com.google.api.AuthProvider$1 found in modules proto-google-common-protos-2.5.0 (com.google.api.grpc:proto-google-common-protos:2.5.0) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0)
Duplicate class com.google.cloud.audit.AuthenticationInfo$Builder found in modules proto-google-common-protos-2.5.0 (com.google.api.grpc:proto-google-common-protos:2.5.0) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0)
Duplicate class com.google.longrunning.Operation$1 found in modules proto-google-common-protos-2.5.0 (com.google.api.grpc:proto-google-common-protos:2.5.0) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0)
How can I resolve this problem? I really need to add the Google Natural Language library to my app.
Updated: The attempt that I have tried but failed:
Firebase Android: Duplicate Protobuf classes found in modules
Duplicate Class while using firebase and google-cloud-texttospeech