Недавно добавили Firebase-Firestore в мой проект android и во время сборки начали получать Дубликаты ссылок на классы в protobuf. * 1001 *
build.gradle
// Top-level build file where you can add configuration options common to all
// sub-projects/modules.
buildscript {
ext.protobufVersion = '0.8.6'
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jcenter.bintray.com" }
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'io.fabric.tools:gradle:1.31.2'
classpath 'com.google.gms:google-services:4.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.41"
classpath 'com.akaita.android:easylauncher:1.3.1'
classpath "com.google.protobuf:protobuf-gradle-plugin:$protobufVersion"
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.akaita.android.easylauncher'
apply plugin: 'com.google.protobuf'
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.fabric.io/public' }
}
configurations {
playstoreImplementation
compatImplementation
freeCompatImplementation
stagingCompatImplementation
}
ext {
supportLibVersion = '28.0.0'
}
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
/*playstoreImplementation('com.google.firebase:firebase-messaging:15.0.2') {
exclude group: 'com.google.firebase', module: 'firebase-core'
}*/
compatImplementation 'androidx.emoji:emoji-appcompat:1.0.0'
freeCompatImplementation 'androidx.emoji:emoji-bundled:1.0.0'
stagingCompatImplementation 'androidx.emoji:emoji-bundled:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'org.sufficientlysecure:openpgp-api:10.0'
implementation 'com.github.inputmice:Android-Image-Cropper:2.7.2'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.emoji:emoji:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'org.bouncycastle:bcmail-jdk15on:1.58'
implementation 'org.whispersystems:signal-protocol-java:2.6.2'
implementation 'org.conscrypt:conscrypt-android:1.3.0'
implementation 'rocks.xmpp:xmpp-addr:0.8.0'
implementation 'org.osmdroid:osmdroid-android:6.0.1'
implementation 'de.measite.minidns:minidns-hla:0.2.4'
implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'com.wefika:flowlayout:0.4.1'
implementation 'net.ypresto.androidtranscoder:android-transcoder:0.2.0'
implementation 'org.hsluv:hsluv:0.2'
//Butterknife dependency
implementation 'com.jakewharton:butterknife:10.2.0'
kapt 'com.jakewharton:butterknife-compiler:10.2.0'
//Network Retrofit and okhttp
implementation('com.squareup.retrofit2:retrofit:2.1.0') {
// exclude Retrofit’s OkHttp dependency module and define your own module import
exclude module: 'okhttp'
}
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.hbb20:ccp:2.2.3'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.crashlytics.sdk.android:answers:1.4.7'
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.firebase:firebase-messaging:20.1.0'
implementation 'com.google.firebase:firebase-config:19.1.0'
implementation 'com.google.firebase:firebase-dynamic-links:19.0.0'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.firebase:firebase-firestore:21.3.1'
implementation 'com.wdullaer:swipeactionadapter:2.0.0'
implementation 'com.wdullaer:materialdatetimepicker:3.2.0'
implementation 'io.michaelrocks:libphonenumber-android:8.10.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'ch.halcyon:squareprogressbar:1.6.4'
implementation 'com.github.zawadz88:material-activity-chooser:0.2.2'
implementation 'com.urbanairship.android:urbanairship-fcm:11.0.1'
implementation 'commons-codec:commons-codec:1.12'
implementation 'com.github.kal72:RackMonthPicker:1.6.0'
implementation "android.arch.work:work-runtime:1.0.0-alpha11"
implementation 'org.apache.commons:commons-lang3:3.9'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.google.android.play:core:1.6.4'
implementation 'com.google.protobuf:protobuf-lite:3.0.1'
//What's new library
implementation('io.github.tonnyl:whatsnew:0.1.2') {
exclude module: 'annotations'
}
//Showcase view library
implementation 'com.github.amlcurran.showcaseview:library:5.4.3'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.mikhaellopez:circularimageview:3.2.0'
implementation 'com.facebook.fresco:fresco:2.0.0'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
//firebase analytics
implementation 'com.google.firebase:firebase-analytics:17.2.0'
//https://jitpack.io/p/kapilmhr/AlphabetIndexFastScrollRecyclerview
implementation 'com.github.kapilmhr:AlphabetIndexFastScrollRecyclerview:1.0.0'
}
ext {
travisBuild = System.getenv("TRAVIS") == "true"
preDexEnabled = System.getProperty("pre-dex", "true")
}
android {
compileSdkVersion 28
signingConfigs {
company{
{...}
}
}
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 120
versionName "2.10.3"
archivesBaseName += "-$versionName"
applicationId "com.company.chat"
resValue "string", "applicationId", applicationId
resValue "string", "app_name", "Company"
multiDexEnabled true
vectorDrawables {
useSupportLibrary = true
}
}
dataBinding {
enabled true
}
dexOptions {
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
preDexLibraries = preDexEnabled && !travisBuild
jumboMode true
javaMaxHeapSize "2g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions("distribution", "emoji")
productFlavors {
/*playstore {
dimension "distribution"
versionNameSuffix "+p"
}*/
free {
dimension "distribution"
{...}
}
staging {
dimension "distribution"
{...}
system {
dimension "emoji"
versionNameSuffix "s"
}
compat {
dimension "emoji"
}
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//versionNameSuffix "r"
signingConfig signingConfigs.company
zipAlignEnabled true
}
debug {
applicationIdSuffix ".dev"
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
disable 'MissingTranslation', 'InvalidPackage', 'MissingQuantity', 'AppCompatResource'
}
subprojects {
afterEvaluate {
if (getPlugins().hasPlugin('android') ||
getPlugins().hasPlugin('android-library')) {
configure(android.lintOptions) {
disable 'AndroidGradlePluginVersion', 'MissingTranslation'
}
}
}
}
packagingOptions {
exclude 'META-INF/BCKEY.DSA'
exclude 'META-INF/BCKEY.SF'
}
// https://proandroiddev.com/how-to-setup-your-android-app-to-use-protobuf-96132340de5c
// Added to fix duplicate classes issue
protobuf {
protoc {
// You still need protoc like in the non-Android case
artifact = 'com.google.protobuf:protoc:3.0.0'
}
plugins {
javalite {
// The codegen for lite comes as a separate artifact
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
// In most cases you don't need the full Java output
// if you use the lite output.
remove java
}
task.plugins {
javalite { }
}
}
}
}
sourceSets{
main.java.srcDirs += "${protobuf.generatedFilesBaseDir}/main/javalite"
}
}
Чтобы исправить ошибку I следуя резолюциям здесь и здесь , я продолжаю получать приведенные ниже ошибки в protobuf.
Duplicate class com.google.protobuf.AbstractMessageLite found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.AbstractMessageLite$Builder found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.AbstractParser found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar) com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.ByteString found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.ByteString$1 found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.ByteString$ByteIterator found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.ByteString$CodedBuilder found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.ByteString$Output found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.CodedInputStream found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.CodedOutputStream found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.CodedOutputStream$OutOfSpaceException found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1) ...
Go to the documentation to learn how to Fix dependency resolution errors.