Accepted answer

below method work for me clean prepare and run.

cordova clean android;
ionic cordova prepare andriod;
ionic cordova run andriod;

"Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex"


build.gradle file and add the following lines to the code

    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 28
        multiDexEnabled true
    }
    ...
}

dependencies {
  implementation 'com.android.support:multidex:1.0.3'
}



copy this code in app\build.gradle file

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support' && requested.name != 'multidex') {
            details.useVersion "${rootProject.ext.supportLibVersion}"
        }
    }
}

Make sure to run gradlew clean before running the code

remove android platform and add it fresh.

Open android/app/build.gradle and add multiDexEnabled true.

android {
    defaultConfig {
        ...
        multiDexEnabled true
    }
}
android {
    defaultConfig {
        ...
        minSdkVersion 16 
        targetSdkVersion 27
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.3' 
}

i tried the this solution and it's works for me

For the above issue you need to change your gradle file like below

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.backpaper.backpapers"
        minSdkVersion 23
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
       // multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.android.material:material:1.1.0-alpha02'
    implementation('com.kc.androidunsplash:androidunsplash:1.0.3') {
        exclude group: 'com.android.support'
        exclude module: 'appcompat-v7'
        exclude module: 'support-v4'
    }
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    //implementation 'androidx.multidex:multidex:2.0.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    androidTestImplementation 'androidx.test:runner:1.1.1'

}

Inside activity_main layout file change it to

<com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab_download"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/stat_sys_download"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:layout_margin="12dp"
        app:elevation="6dp"
        app:pressedTranslationZ="12dp"/>

Inside MainActivity import

   import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.appcompat.app.AppCompatActivity;

 This solved it for me.

  1. clean [ from terminal cordova clean ]
  2. rebuild [ from terminal ionic cordova build android]
  • Remove android platform

    ionic cordova platform rm android

  • Remove plugins related to support, gradle and/or firebase versions control. In my case it was a little bit weird, I removed the local-notifications plugin.

  • Add androidX plugins

    cordova plugin add cordova-plugin-androidx

    cordova plugin add cordova-plugin-androidx-adapter