添加适用于Android的Firebase应用内消息传递SDK后出现错误

时间:2018-12-28 14:30:58

标签: android firebase

将Firebase应用内消息传递SDK添加到build.gradle之后,在构建项目Program type already present: com.google.common.annotations.Beta之后,我始终收到此错误消息 我已经尝试了herehere提出的大多数解决方案,但对我而言不起作用。

下面是我在项目上使用的依赖库

  def room_version = "1.1.1"
def supportLibVersion = '28.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.greenrobot:eventbus:3.0.0'
implementation 'org.apache.commons:commons-lang3:3.5'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.github.ganfra:material-spinner:2.0.0'
implementation 'com.github.d-max:spots-dialog:0.7@aar'
implementation 'id.zelory:compressor:2.1.0'
implementation 'org.sufficientlysecure:html-textview:3.6'
implementation 'com.github.medyo:android-about-page:1.2.4'


testImplementation 'junit:junit:4.12'
implementation 'com.github.mirrajabi:search-dialog:1.2.3'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
    transitive = true
}
implementation 'com.miguelcatalan:materialsearchview:1.4.0'

//support library
implementation "com.android.support:support-v4:$supportLibVersion"
implementation "com.android.support:appcompat-v7:$supportLibVersion"
implementation "com.android.support:design:$supportLibVersion"
implementation "com.android.support:cardview-v7:$supportLibVersion"
implementation "com.android.support:recyclerview-v7:$supportLibVersion"
implementation "com.android.support:customtabs:$supportLibVersion"

// firebase
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-ads:17.1.2'
implementation 'com.google.firebase:firebase-appindexing:17.1.0'
implementation 'com.google.firebase:firebase-config:16.1.2'
implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.4'



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

//google play services
implementation "com.google.android.gms:play-services-location:16.0.0"
implementation 'com.google.android.gms:play-services-auth:16.0.1'

// room
implementation "android.arch.persistence.room:runtime:$room_version"
kapt "android.arch.persistence.room:compiler:$room_version"

//rx java
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.10'

//people api
implementation 'com.google.apis:google-api-services-people:v1-rev277-1.23.0'

//expandable layout
implementation 'com.github.aakira:expandable-layout:1.6.0@aar'
implementation 'com.thoughtbot:expandablerecyclerview:1.3'

//FlutterWave RavePay
implementation 'com.github.Flutterwave:rave-android:1.0.25'

//day picker
implementation 'com.github.DavidProdinger:weekdays-selector:1.0.4'

//Facebook SDK
implementation 'com.facebook.android:facebook-android-sdk:4.38.1'
implementation 'com.facebook.android:facebook-core:4.38.1'
implementation 'com.facebook.android:facebook-marketing:4.38.1'
implementation 'com.facebook.android:audience-network-sdk:5.+'

下面是完整的错误日志

  

org.gradle.api.tasks.TaskExecutionException:任务':app:transformClassesWithMultidexlistForDebug'的执行失败。       在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)       在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)       在org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)处       在org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)       在org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)       在org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)       在org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)处       在org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)       在org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)       在org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)处       在org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)       在org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)       在org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)       在org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)       在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker $ 1.run(DefaultTaskGraphExecuter.java:256)       在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)处       在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)       在org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)       在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)       在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)处       在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)处       在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)处       在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.access $ 200(DefaultTaskPlanExecutor.java:79)       在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:104)       在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:98)       在org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)处       在org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597)       在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)       在org.gradle.internal.concurrent.ExecutorPolicy $ CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)       在org.gradle.internal.concurrent.ManagedExecutorImpl $ 1.run(ManagedExecutorImpl.java:46)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)       在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)       在org.gradle.internal.concurrent.ThreadFactoryImpl $ ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)       在java.lang.Thread.run(Thread.java:745)   引起原因:java.lang.RuntimeException:com.android.build.api.transform.TransformException:生成主dex列表时出错。       在com.android.builder.profile.Recorder $ Block.handleException(Recorder.java:55)       在com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)       在com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:230)       在sun.reflect.GeneratedMethodAccessor1087.invoke(未知来源)       在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)       在java.lang.reflect.Method.invoke(Method.java:498)       在org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)       在org.gradle.api.internal.project.taskfactory.IncrementalTask​​Action.doExecute(IncrementalTask​​Action.java:50)       在org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)       在org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)       在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter $ 1.run(ExecuteActionsTaskExecuter.java:124)       在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)处       在org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)       在org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)       在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)       在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)处       在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)       ...更多33   引起原因:com.android.build.api.transform.TransformException:生成主dex列表时出错。       在com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:144)       在com.android.build.gradle.internal.pipeline.TransformTask $ 2.call(TransformTask.java:239)       在com.android.build.gradle.internal.pipeline.TransformTask $ 2.call(TransformTask.java:235)       在com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)       ...另外48个   引起原因:com.android.builder.multidex.D8MainDexList $ MainDexListException:com.android.tools.r8.errors.CompilationError:程序类型已存在:com.google.common.annotations.Beta       在com.android.builder.multidex.D8MainDexList.generate(D8MainDexList.java:87)       在com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:131)       ...另外51个   引起原因:com.android.tools.r8.errors.CompilationError:程序类型已存在:com.google.common.annotations.Beta       在com.android.tools.r8.utils.ProgramClassCollection.resolveClassConflictImpl(ProgramClassCollection.java:64)       在com.android.tools.r8.utils.ProgramClassCollection.lambda $ create $ 0(ProgramClassCollection.java:25)       在java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:1990)       在com.android.tools.r8.utils.ProgramClassCollection.create(ProgramClassCollection.java:24)       在com.android.tools.r8.graph.LazyLoadedDexApplication $ Builder.build(LazyLoadedDexApplication.java:124)       在com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:123)       在com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:86)       在com.android.tools.r8.GenerateMainDexList.run(GenerateMainDexList.java:40)       在com.android.tools.r8.GenerateMainDexList.run(GenerateMainDexList.java:110)       在com.android.builder.multidex.D8MainDexList.generate(D8MainDexList.java:83)       ... 52更多

3 个答案:

答案 0 :(得分:0)

从菜单File->Invalidate Caches/Restart -> Invalidate and Restart尝试

答案 1 :(得分:0)

您可以使用gradle dependencies打印gradle依赖图。检查图以找到哪些库使用此依赖项com.google.common.annotations.Beta。然后,您可以使用gradle exclude规则来排除罪魁祸首的传递依存关系。

答案 2 :(得分:0)

如果您具有 com.google.firebase:firebase-core 库,请删除。

根据firebase文档。

不再添加Android库com.google.firebase:firebase-core。 该SDK包括适用于Google Analytics(分析)的Firebase SDK。现在,要使用Google Analytics(分析)(或要求或建议使用Google Analytics(分析)的任何Firebase产品),您需要明确添加Analytics(分析)依赖项: com.google.firebase:firebase-analytics:17.2.0。