更新我的Firebase和Play服务依赖项以及Play服务插件后,我的项目无法构建。我尝试了多次Clean-Rebuild,我的应用启用了MultiDex。恢复到我原来的依赖版本也不是一个选项,因为我为云函数添加了一个依赖项,其中最新版本与我的其他firebase依赖项不兼容。我可以在Android问题
下看到以下内容Program type already present: android.arch.core.util.Function
Message{kind=ERROR, text=Program type already present: android.arch.core.util.Function, sources=[Unknown source file], tool name=Optional.of(D8)}
我还在“运行任务”
下看到一条错误消息org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
我的gradle依赖
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
implementation 'com.android.support:multidex:1.0.3'
//Android Support
implementation 'com.android.support:support-v13:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation "com.android.support:cardview-v7:27.1.1"
implementation "com.android.support:customtabs:27.1.1"
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation "com.android.support:support-v4:27.1.1"
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-analytics:16.0.0'
implementation 'com.google.firebase:firebase-appindexing:15.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1' //Maintain compatibility with com.firebaseui:firebase-ui-firestore
implementation 'com.google.firebase:firebase-firestore:17.0.1' //Maintain compatibility with com.firebaseui:firebase-ui-firestore
implementation 'com.google.firebase:firebase-functions:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
//implementation 'com.google.firebase:firebase-storage:16.0.1' //Maintain compatibility with com.firebaseui:firebase-ui-firestore
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true
}
//implementation 'com.google.firebase:firebase-invites:16.0.0'
implementation 'com.google.firebase:firebase-config:16.0.0'
//Google Play
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
//Stream Support
implementation 'net.sourceforge.streamsupport:android-retrostreams:1.6.1'
implementation 'net.sourceforge.streamsupport:android-retroflow:1.6.1'
implementation 'net.sourceforge.streamsupport:android-retrofuture:1.6.1'
//Location
implementation 'io.nlopez.smartlocation:library:3.3.3'
//Firebase UI
implementation 'com.firebaseui:firebase-ui-firestore:4.0.0'
//Facebook
implementation 'com.facebook.android:facebook-login:4.31.0'
//Search
implementation 'com.algolia:algoliasearch-android:3.14.1'
//Butterknife
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//UI Elements for layout staggering
implementation 'com.google.android:flexbox:0.3.2'
//Image Handling Library
implementation 'com.facebook.fresco:fresco:1.8.0'
// UI Element for Country-code
implementation 'com.hbb20:ccp:2.1.2'
// UI Element for OTP
implementation 'com.github.GoodieBag:Pinview:v1.3'
//Loading indicator using shimmer
implementation 'io.supercharge:shimmerlayout:2.0.0'
//UI Element for Tooltip
implementation 'it.sephiroth.android.library.targettooltip:target-tooltip-library:1.3.15'
//Date/Time Pickers for Hangout Creation
implementation 'com.wdullaer:materialdatetimepicker:3.5.1'
//UI Element from Drop-down boxes
implementation('com.weiwangcn.betterspinner:library-material:1.1.0') {
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'appcompat-v4'
}
//JSON Handling
implementation 'com.google.code.gson:gson:2.8.2'
//Permissions using RxPermissions
implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5@aar'
//RxBindings for Platform
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-recyclerview-v7:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.1.1'
//Logging
implementation 'com.jakewharton.timber:timber:4.6.0'
//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'
}
答案 0 :(得分:48)
我找到了一些伟人在GitHub上发布的解决方案。无需降级firebaseUI数据库,您可以添加以下通用公共和运行时依赖项:
//Arch
implementation "android.arch.core:runtime:1.1.1"
implementation "android.arch.core:common:1.1.1"
只需将这些添加到您的应用程序:模块依赖项部分,就可以构建它。
答案 1 :(得分:16)
我的项目使用最新版本的firebase core, database, messaging and auth
依赖项和最新classpath 'com.google.gms:google-services:4.0.1'
App/build.gradle
dependencies {
// Tab Layout and ViewPager
implementation 'com.android.support:design:27.1.1'
// firebase dependencies
// implementation 'com.firebaseui:firebase-ui-database:4.0.0' Source of error
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1'
}
build.gradle
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.0.1'
}
}
添加implementation 'com.firebaseui:firebase-ui-database:4.0.0'
显示此错误:
程序类型已存在:android.arch.core.util.Function
消息{kind = ERROR,text =程序类型已存在:android.arch.core.util.Function,sources = [未知源文件],工具名称= Optional.of(D8)}
解决方案是将implementation 'com.firebaseui:firebase-ui-database:4.0.0'
降级为implementation 'com.firebaseui:firebase-ui-database:3.3.1'
,如下所示:
App/build.gradle
dependencies {
// Tab Layout and ViewPager
implementation 'com.android.support:design:27.1.1'
// firebase dependencies
implementation 'com.firebaseui:firebase-ui-database:3.1.1' // No trouble in compiling
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1'
}
我希望Google能够在未来的更新中解决此问题。
希望有所帮助!
答案 2 :(得分:1)
解决方案是在android studio中的build.gradle上添加以下实现。希望对您有所帮助。
["d",1], ["e",2]
答案 3 :(得分:0)
尝试用以下内容替换gradle文件:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'
}
}
allprojects {
repositories {
maven { url 'https://jitpack.io' }
jcenter()
google()
}
}
和模块:app grandle with:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 16
targetSdkVersion 27
multiDexEnabled true
}
buildTypes {
debug{
debuggable true
minifyEnabled false
}
release {
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
repositories {
jcenter()
google()
maven { url 'https://maven.google.com' }
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
implementation 'com.android.support:multidex:1.0.3'
//Android Support
implementation 'com.android.support:support-v13:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation "com.android.support:cardview-v7:27.1.1"
implementation "com.android.support:customtabs:27.1.1"
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation "com.android.support:support-v4:27.1.1"
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-analytics:16.0.0'
implementation 'com.google.firebase:firebase-appindexing:15.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1' //Maintain compatibility with com.firebaseui:firebase-ui-firestore
implementation 'com.google.firebase:firebase-firestore:17.0.1' //Maintain compatibility with com.firebaseui:firebase-ui-firestore
implementation 'com.google.firebase:firebase-functions:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
//implementation 'com.google.firebase:firebase-storage:16.0.1' //Maintain compatibility with com.firebaseui:firebase-ui-firestore
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true
}
//implementation 'com.google.firebase:firebase-invites:16.0.0'
implementation 'com.google.firebase:firebase-config:16.0.0'
//Google Play
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
//Stream Support
implementation 'net.sourceforge.streamsupport:streamsupport:1.6.0'
implementation 'net.sourceforge.streamsupport:streamsupport-cfuture:1.6.0'
implementation 'net.sourceforge.streamsupport:streamsupport-atomic:1.6.0'
implementation 'net.sourceforge.streamsupport:streamsupport-flow:1.6.0'
implementation 'net.sourceforge.streamsupport:streamsupport-literal:1.6.0'
//Location
implementation 'io.nlopez.smartlocation:library:3.3.3'
//Firebase UI
implementation 'com.firebaseui:firebase-ui-firestore:4.0.0'
//Facebook
implementation 'com.facebook.android:facebook-login:4.32.0'
//Search
implementation 'com.algolia:algoliasearch-android:3.14.1'
//Butterknife
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//UI Elements for layout staggering
implementation 'com.google.android:flexbox:0.3.2'
//Image Handling Library
implementation 'com.facebook.fresco:fresco:1.8.0'
// UI Element for Country-code
implementation 'com.hbb20:ccp:2.1.2'
// UI Element for OTP
implementation 'com.github.GoodieBag:Pinview:v1.3'
//Loading indicator using shimmer
implementation 'io.supercharge:shimmerlayout:2.0.0'
//UI Element for Tooltip
implementation 'it.sephiroth.android.library.targettooltip:target-tooltip-library:1.3.15'
//Date/Time Pickers for Hangout Creation
implementation 'com.wdullaer:materialdatetimepicker:3.5.1'
//UI Element from Drop-down boxes
implementation('com.weiwangcn.betterspinner:library-material:1.1.0') {
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'appcompat-v4'
}
//JSON Handling
implementation 'com.google.code.gson:gson:2.8.2'
//Permissions using RxPermissions
implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5@aar'
//RxBindings for Platform
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-recyclerview-v7:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.1.1'
//Logging
implementation 'com.jakewharton.timber:timber:4.6.0'
//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'
答案 4 :(得分:0)
程序类型已存在:android.arch.core.util.Function 消息{种类=错误,文本=程序类型已存在:android.arch.core.util.Function,来源= [未知源文件],工具名称= Optional.of(D8)}
我在上面也遇到了同样的问题,这是因为我没有包含核心。
implementation 'com.google.firebase:firebase-core:16.0.1'
请注意,您的某些依赖项是16.0.1,建议您将核心升级到16.0.1,而不是16.0.0。
在下面附上了我的依赖项以供参考,希望对您有用。
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.firebaseui:firebase-ui-database:4.1.0'