使用高于 15.0.0 版本的 FireStore 导致错误 [英] Using FireStore later than 15.0.0 version is causing an error

查看:25
本文介绍了使用高于 15.0.0 版本的 FireStore 导致错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 'com.google.firebase:firebase-firestore:' 超过 15.0.0 构建我的应用程序时,它会出现运行任务错误:

程序类型已经存在:com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream

我已经搜索过这个问题,发现唯一的解决方案是使用 15.0.0 而不是 17.0.4 版本的 FireStore 有没有其他方法可以在我的项目中使用最新版本?

等级构建扫描链接:

我看到其中一个是 700 多行,所以如果您需要查看它们,我可以将它们上传到任何网站.

<小时>

具有 FireSotre 实现的后端的 Gradle:

应用插件:'com.android.library'安卓 {compileSdkVersion 27默认配置{minSdk 版本 15目标SDK版本27版本代码 1版本名称1.0"testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}构建类型{发布 {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}编译选项{sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8}}依赖{实现文件树(包括:['*.jar'],目录:'libs')//模块实施项目(路径:':shared.resources')//用户界面实现com.mikepenz:iconics-core:${versions.iconicsLib}"实现com.mikepenz:iconics-views:${versions.iconicsLib}"实现 'com.mikepenz:ionicons-typeface:2.0.1.4@aar'实现 'com.unstoppable:submitbutton:1.1.3'实现('com.lamudi.phonefield:phone-field:0.1.3@aar'){传递 = 真}实现 'com.infideap.blockedittext:block-edittext:0.0.6'实现 'com.firebaseui:firebase-ui-auth:4.0.0'//支持实现com.android.support:appcompat-v7:${versions.supportLib}"实现 'com.android.support.constraint:constraint-layout:1.1.2'//火力基地实现 'com.google.firebase:firebase-core:16.0.1'实现 'com.google.firebase:firebase-auth:16.0.2'实现 'com.google.firebase:firebase-firestore:17.0.4'//社交媒体实现 'com.facebook.android:facebook-android-sdk:4.34.0'实现 'com.twitter.sdk.android:twitter-core:3.3.0@aar'//避免混合版本实现com.android.support:support-media-compat:${versions.supportLib}"实现com.android.support:support-v4:${versions.supportLib}"//木材实现com.jakewharton.timber:timber:${versions.timberLib}"//测试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'}应用插件:'com.google.gms.google-services'

顶级 Gradle

//顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项.构建脚本{分机{版本 = [支持库:27.1.1",archLib: "1.1.1",ButterKnifeLib: '8.8.1',约束布局库:'1.1.2',junitLib: '4.12',testRunnerLib: '1.0.2',图标库:'3.0.4@aar',木材库:'4.7.1']}存储库{谷歌()jcenter()}依赖{类路径 'com.android.tools.build:gradle:3.1.3'类路径 'com.google.gms:google-services:4.0.2'}}所有项目{存储库{谷歌()jcenter()maven { url 'https://jitpack.io' }maven{ url "https://dl.bintray.com/infideap2/Block-EditText" }}}任务清理(类型:删除){删除 rootProject.buildDir}

应用 Gradle

应用插件:'com.android.application'安卓 {compileSdkVersion 27默认配置{applicationId "com.tech.futureteric.goodmorning"//TODO 在 api 15 上支持 com.firebaseui:firebase-ui-authminSdk 版本 16目标SDK版本27版本代码 1版本名称1.0-alpha"multiDexEnabled truetestInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}构建类型{发布 {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}buildTypes.each {it.buildConfigField "String", "UNSPLASH_API_KEY", ""$System.env.UNSPLASH_API_KEY""}}编译选项{sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8}}依赖{实现文件树(包括:['*.jar'],目录:'libs')//模块实现项目(路径:':lockscreen.ui')实施项目(路径:':intro.ui')实施项目(路径:':shared.resources')实施项目(路径:':后端')实施项目(路径:':find.friends')//锁屏界面库实现 'com.github.HITGIF:TextFieldBoxes:1.4.4'//关于 ui 库实现com.mikepenz:aboutlibraries:6.1.0"实现 'com.github.jrvansuita:MaterialAbout:0.2.3'//木材实现com.jakewharton.timber:timber:${versions.timberLib}"//生命周期和持久性实现android.arch.lifecycle:extensions:${versions.archLib}"实现android.arch.lifecycle:viewmodel:${versions.archLib}"实现android.arch.persistence.room:runtime:${versions.archLib}"annotationProcessor "android.arch.persistence.room:compiler:${versions.archLib}"//注入实现 'javax.inject:javax.inject:1@jar'//牛油刀实现com.jakewharton:butterknife:${versions.butterKnifeLib}"annotationProcessor "com.jakewharton:butterknife-compiler:${versions.butterKnifeLib}"//改造实现 'com.squareup.retrofit2:retrofit:2.4.0'实现 'com.squareup.retrofit2:converter-gson:2.3.0'//支持库实现com.android.support:appcompat-v7:${versions.supportLib}"实现com.android.support:design:${versions.supportLib}"实现com.android.support:support-annotations:${versions.supportLib}"实现com.android.support:support-v4:${versions.supportLib}"实现com.android.support:recyclerview-v7:${versions.supportLib}"//避免混合版本实现com.android.support:exifinterface:${versions.supportLib}"//约束布局实现com.android.support.constraint:constraint-layout:${versions.constraintLayuotLib}"实现 'cn.hugeterry.coordinatortablayout:coordinatortablayout:1.2.2'//多索引实现 'com.android.support:multidex:1.0.3'//毕加索实现 'com.squareup.picasso:picasso:2.71828'//测试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

应用插件:'com.android.library'安卓 {compileSdkVersion 27默认配置{minSdk 版本 15目标SDK版本27版本代码 1版本名称1.0"testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}构建类型{发布 {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}编译选项{sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8}}依赖{实现文件树(包括:['*.jar'],目录:'libs')//模块实施项目(路径:':shared.resources')实施项目(路径:':后端')//用户界面实现 'com.github.florent37:materialtextfield:1.0.7'//支持实现 'com.android.support:appcompat-v7:27.1.1'实现 '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'实现 'com.android.support:design:27.1.1'}

intro.ui Gradle

应用插件:'com.android.library'安卓 {compileSdkVersion 27默认配置{minSdk 版本 15目标SDK版本27版本代码 1版本名称1.0"testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}构建类型{发布 {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}编译选项{sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8}}依赖{实现文件树(包括:['*.jar'],目录:'libs')//模块实施项目(路径:':后端')实施项目(路径:':shared.resources')//介绍界面实施 'com.nightonke:boommenu:2.1.1'//支持实现com.android.support:appcompat-v7:${versions.supportLib}"实现com.android.support:support-v4:${versions.supportLib}"//测试实现 '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

应用插件:'com.android.library'安卓 {compileSdkVersion 27默认配置{minSdk 版本 15目标SDK版本27版本代码 1版本名称1.0"testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}构建类型{发布 {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}编译选项{sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8}}依赖{实现文件树(包括:['*.jar'],目录:'libs')//butterKnife 不用于此项目,因为问题 #1130 与库//@link (https://github.com/JakeWharton/butterknife/issues/1130)//TODO (1) 是否有任何资源可以从中学习如何评论和添加可点击文本?//支持实现com.android.support:appcompat-v7:${versions.supportLib}"实现 'com.android.support:recyclerview-v7:27.1.1'//约束实现com.android.support.constraint:constraint-layout:${versions.constraintLayuotLib}"//动画实现 'com.jaredrummler:animated-svg-view:1.0.5'//测试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

应用插件:'com.android.library'安卓 {compileSdkVersion 27默认配置{minSdk 版本 15目标SDK版本27版本代码 1版本名称1.0"testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}构建类型{发布 {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}编译选项{sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8}}依赖{实现文件树(包括:['*.jar'],目录:'libs')//图标实现com.mikepenz:iconics-core:3.0.4@aar"实现 'com.mikepenz:ionicons-typeface:2.0.1.4@aar'//对话界面实现 'com.afollestad.material-dialogs:core:0.9.6.0'//支持实现com.android.support:appcompat-v7:${versions.supportLib}"//避免混合版本实现 'com.android.support:recyclerview-v7:27.1.1'//木材实现com.jakewharton.timber:timber:${versions.timberLib}"//测试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'}

解决方案

您需要通过排除重复项来防止重复类:

实现(com.google.firebase:firebase-firestore:17.0.4"){排除组:com.google.protobuf"}

可能是,您必须排除 com.google.guava,而是...

检查 ./gradlew :app:dependencies 然后添加所需的 exclude 语句.

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

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

解决方案

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.

这篇关于使用高于 15.0.0 版本的 FireStore 导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆