Error:Execution failed for task ‘: app:transformDexArchiveWithExternalLibsDexMergerForDebug The solution

specific error message is as follows:

AGPBI: {"kind":"error","text":"Program type already present: android.support.v4.app.FragmentTransitionCompat21$1","sources":[{}],"tool":"D8"}
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

there are several methods (the last one is available) :

1. Add “multiDexEnabled true” to defaultConfig

android {} :

defaultConfig {
        multiDexEnabled true
        applicationId "com.example.m1571.mycolorfulnews"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

this method has no effect on my project

2. Add:

to gradle. Properties China

android.useAndroidX=true
android.enableJetifier=true

this method has no effect on my project

3. Remove conflicting dependencies:

implementation 'com.android.support:appcompat-v7:28.0.0'

delete the above v7 package, you can run

Read More: