Using FireStore later than 15.0.0 version is causi

2019-02-20 15:48发布

When I build my app with 'com.google.firebase:firebase-firestore:' more than 15.0.0 it gives a Run tasks error:

Program type already present: com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream

I have searched about this problem and found the only solution is to use 15.0.0 instead of 17.0.4 version of FireStore is there is any other way to use the latest versions in my project?

Grade build scan links: when using 15.0.0, when using 17.0.4


Here is the 3 LimitedInputStream.class that IDE found

enter image description here

I saw one of them is 700+ line so if you need to look at them I can upload them to any website.


Gradle of the backend that has the FireSotre implementation:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 27
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner         "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')

// modules
implementation project(path: ':shared.resources')

// ui
implementation "com.mikepenz:iconics-core:${versions.iconicsLib}"
implementation "com.mikepenz:iconics-views:${versions.iconicsLib}"
implementation 'com.mikepenz:ionicons-typeface:2.0.1.4@aar'
implementation 'com.unstoppable:submitbutton:1.1.3'
implementation('com.lamudi.phonefield:phone-field:0.1.3@aar') {
    transitive = true
}
implementation 'com.infideap.blockedittext:block-edittext:0.0.6'
implementation 'com.firebaseui:firebase-ui-auth:4.0.0'

// support
implementation "com.android.support:appcompat-v7:${versions.supportLib}"
implementation 'com.android.support.constraint:constraint-layout:1.1.2'

// firebase
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-firestore:17.0.4'

// social media
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation 'com.twitter.sdk.android:twitter-core:3.3.0@aar'

// mixed versions avoidance
implementation "com.android.support:support-media-compat:${versions.supportLib}"
implementation "com.android.support:support-v4:${versions.supportLib}"

// timber
implementation "com.jakewharton.timber:timber:${versions.timberLib}"

// testing
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'
}
apply plugin: 'com.google.gms.google-services'

Top level Gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext{
    versions = [
            supportLib: "27.1.1",
            archLib: "1.1.1",
            butterKnifeLib: '8.8.1',
            constraintLayuotLib: '1.1.2',
            junitLib: '4.12',
            testRunnerLib: '1.0.2',
            iconicsLib: '3.0.4@aar',
            timberLib: '4.7.1'
    ]
}

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath 'com.google.gms:google-services:4.0.2'
}
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        maven{ url "https://dl.bintray.com/infideap2/Block-EditText" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

App Gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.tech.futureteric.goodmorning"
    // TODO support com.firebaseui:firebase-ui-auth on api 15
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0-alpha"
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    buildTypes.each {
        it.buildConfigField "String", "UNSPLASH_API_KEY", "\"$System.env.UNSPLASH_API_KEY\""
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

// modules
implementation project(path: ':lockscreen.ui')
implementation project(path: ':intro.ui')
implementation project(path: ':shared.resources')
implementation project(path: ':backend')
implementation project(path: ':find.friends')

// lockScreen ui libraries
implementation 'com.github.HITGIF:TextFieldBoxes:1.4.4'

// about ui libraries
implementation "com.mikepenz:aboutlibraries:6.1.0"
implementation 'com.github.jrvansuita:MaterialAbout:0.2.3'

// timber
implementation "com.jakewharton.timber:timber:${versions.timberLib}"

// lifecycle and persistence
implementation "android.arch.lifecycle:extensions:${versions.archLib}"
implementation "android.arch.lifecycle:viewmodel:${versions.archLib}"
implementation "android.arch.persistence.room:runtime:${versions.archLib}"
annotationProcessor "android.arch.persistence.room:compiler:${versions.archLib}"

// injection
implementation 'javax.inject:javax.inject:1@jar'

// butterKnife
implementation "com.jakewharton:butterknife:${versions.butterKnifeLib}"
annotationProcessor "com.jakewharton:butterknife-compiler:${versions.butterKnifeLib}"

// retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

// support libraries
implementation "com.android.support:appcompat-v7:${versions.supportLib}"
implementation "com.android.support:design:${versions.supportLib}"
implementation "com.android.support:support-annotations:${versions.supportLib}"
implementation "com.android.support:support-v4:${versions.supportLib}"
implementation "com.android.support:recyclerview-v7:${versions.supportLib}"

// mixed versions avoidance
implementation "com.android.support:exifinterface:${versions.supportLib}"

// constraint layout
implementation "com.android.support.constraint:constraint-layout:${versions.constraintLayuotLib}"
implementation 'cn.hugeterry.coordinatortablayout:coordinatortablayout:1.2.2'

// multi-dex
implementation 'com.android.support:multidex:1.0.3'

// picasso
implementation 'com.squareup.picasso:picasso:2.71828'

// testing
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'
}

find.friends Gradle

apply plugin: 'com.android.library'

android {
compileSdkVersion 27
defaultConfig {
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

// modules
implementation project(path: ':shared.resources')
implementation project(path: ':backend')

// ui
implementation 'com.github.florent37:materialtextfield:1.0.7'

// support
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'

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'
implementation 'com.android.support:design:27.1.1'
}

intro.ui Gradle

apply plugin: 'com.android.library'

android {
compileSdkVersion 27
defaultConfig {
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

// modules
implementation project(path: ':backend')
implementation project(path: ':shared.resources')

// intro ui
implementation 'com.nightonke:boommenu:2.1.1'

// support
implementation "com.android.support:appcompat-v7:${versions.supportLib}"
implementation "com.android.support:support-v4:${versions.supportLib}"

// testing
implementation 'com.android.support.constraint:constraint-layout:1.1.2'

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'
}

lobkscreen.ui Gradle

apply plugin: 'com.android.library'

android {
compileSdkVersion 27
defaultConfig {
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// butterKnife is not used with this projects as issue #1130 with libraries
// @link (https://github.com/JakeWharton/butterknife/issues/1130)
// TODO (1) is there is any resource to learn from it how to comment and add clickable text?
// support
implementation "com.android.support:appcompat-v7:${versions.supportLib}"
implementation 'com.android.support:recyclerview-v7:27.1.1'
// constraint
implementation "com.android.support.constraint:constraint-layout:${versions.constraintLayuotLib}"
// animations
implementation 'com.jaredrummler:animated-svg-view:1.0.5'
// testing
testImplementation "junit:junit:${versions.junitLib}"
androidTestImplementation "com.android.support.test:runner:${versions.testRunnerLib}"
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

shared.resources Gradle

apply plugin: 'com.android.library'

android {
compileSdkVersion 27
defaultConfig {
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

// icons
implementation "com.mikepenz:iconics-core:3.0.4@aar"
implementation 'com.mikepenz:ionicons-typeface:2.0.1.4@aar'

// dialog ui
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'

// support
implementation "com.android.support:appcompat-v7:${versions.supportLib}"

// mixed versions avoidance
implementation 'com.android.support:recyclerview-v7:27.1.1'

// timber
implementation "com.jakewharton.timber:timber:${versions.timberLib}"

// testing
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'
}

2条回答
唯我独甜
2楼-- · 2019-02-20 16:25

you need to prevent duplicate classes, by excluding the duplicates:

implementation ("com.google.firebase:firebase-firestore:17.0.4") {
    exclude group: "com.google.protobuf"
}

it may be, that you have to exclude com.google.guava, instead...

check with ./gradlew :app:dependencies and then add the required exclude statements.

查看更多
爷的心禁止访问
3楼-- · 2019-02-20 16:27

In your gradle file where firestore has been defined/declared the dependency of phone field

(implementation('com.lamudi.phonefield:phone-field:0.1.3@aar') {
    transitive = true
})

is causing the problem with protobuf where a google code dependency clashes

查看更多
登录 后发表回答