每当我尝试同步Gradle时,都会显示此错误。程序类型已经存在:com.google.protobuf.AbstractMessageLite $ Builder $ LimitedInputStream
我正在使用AndroidStudio 3.1.3。我还遵循了Firebase上的文档,该文档介绍了如何入门,但是它没有用。我尝试搜索,但无法获得太多信息。我读到有关排除protobuf的信息,但实际上也没有用。感谢您的帮助。
显然也注释掉了与Firestore兼容的行,因此问题出在Firestore依赖项上。
以下是我的app.buildle版本:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
//on laptop
//buildToolsVersion "26.0.2"
defaultConfig {
applicationId "application_id_name(sanitized)"
minSdkVersion 19
targetSdkVersion 26
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '27.0.3'
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'project.properties'
exclude 'META-INF/INDEX.LIST'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.firebaseui:firebase-ui-auth:4.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
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'
api 'com.google.android.gms:play-services-vision:15.0.0'
api 'com.android.support:multidex:1.0.3'
api 'com.google.cloud:google-cloud-storage:1.27.0'
implementation 'com.google.firebase:firebase-firestore:17.0.2'
implementation 'com.jjoe64:graphview:4.2.2'
}
apply plugin: 'com.google.gms.google-services'
这是我的项目的build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
//classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
尝试排除protobuf时遇到此错误。找不到类型为org.gradle的对象的参数[build_60vj88gllutj4zz7i0ca1ojkd $ _run_closure2 $ _closure7 @ 3b52fa7d]的方法com.google.firebase:firebase-firestore:17.0.2()。 api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler。
implementation 'com.google.firebase:firebase-firestore:17.0.2'{
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}
答案 0 :(得分:1)
升级此:
classpath 'com.google.gms:google-services:3.2.1'
对此:
classpath 'com.google.gms:google-services:4.0.1'
能够使用最新版本的Firebase库。
执行./gradlew :app:dependencies
之后,您可以看到'com.google.firebase:firebase-firestore:17.0.2'
和'com.google.cloud:google-cloud-storage:1.27.0'
都依赖于protobuf
,从而导致了此问题。
由于Op没有使用google-cloud-storage
,然后删除了'com.google.cloud:google-cloud-storage:1.27.0'
,从而解决了此问题。