web-dev-qa-db-ja.com

「プログラムの種類は既に存在します:Android.Arch.core.util.Function」でビルドが失敗します

FirebaseおよびPlay Servicesの依存関係とPlay Servicesプラグインを更新した後、プロジェクトのビルドに失敗します。複数の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'
}
27
Karan Modi

ある素晴らしい男がGitHubに投稿したソリューションを見つけました。 firebaseUIデータベースをダウングレードする代わりに、以下のArch共通およびランタイム依存関係を追加できます。

//Arch
    implementation "Android.Arch.core:runtime:1.1.1"
    implementation "Android.Arch.core:common:1.1.1"

これらをアプリに追加するだけです。モジュールの依存関係セクションで、ビルドを知っています。

50
Aditya Tandon

私のプロジェクトは、最新バージョンの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がこの問題を解決することを願っています。

お役に立てば幸いです!

16
Omar Abdelhafiz

解決策は、Android studioのbuild.gradleに以下の実装を追加することです。それが役に立てば幸い。

 implementation "Android.Arch.core:runtime:$version"
 implementation "Android.Arch.core:common:$version"
1
johnwebi

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()
    }
}

そして、Module: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'
0

プログラムの種類は既に存在します:Android.Arch.core.util.Function Message {kind = ERROR、text =プログラムの種類は既に存在します:Android.Arch.core.util.Function、sources = [不明なソースファイル]、ツール名=オプション。 of(D8)}

上記と同じ問題が発生しましたが、それはコアが含まれていなかったためです。

implementation 'com.google.firebase:firebase-core:16.0.1'

依存関係の一部は16.0.1であることに注意してください。コアを16.0.0ではなく16.0.1にアップグレードすることをお勧めします

参考のために以下の依存関係を囲みました。これがあなたの役に立つことを願っています。

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'
0
lonelearner