Ionic build failure due to Manifest merger failed

I am trying to build using - ionic Cordova build android but getting an error with the following details from today and was running fine until yesterday-

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add ‘tools:replace=“android:appComponentFactory”’ to element at AndroidManifest.xml:5:5-76:19 to override.

Here are the details of my ionic project -
Ionic:

ionic (Ionic CLI) : 4.12.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.1

Cordova:

cordova (Cordova CLI) : 7.1.0
Cordova Platforms : android 8.0.0, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 1.2.1, (and 25 other plugins)

System:

Android SDK Tools : 26.1.1 (/Users/mervejraj/Library/Android/sdk)
NodeJS : v10.15.3 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS Mojave
Xcode : Xcode 10.1 Build version 10B61

Cordova Plugins Info-

clevertap-cordova 2.1.1 “CleverTap”
cordova-clipboard 1.2.1 “Clipboard”
cordova-plugin-advanced-http 1.11.1 “Advanced HTTP plugin”
cordova-plugin-android-permissions 1.0.0 “Permissions”
cordova-plugin-app-version 0.1.9 “AppVersion”
cordova-plugin-camera 4.0.3 “Camera”
cordova-plugin-device 2.0.2 “Device”
cordova-plugin-facebook4 2.5.0 “Facebook Connect”
cordova-plugin-file 6.0.1 “File”
cordova-plugin-file-transfer 1.7.1 “File Transfer”
cordova-plugin-gallery-refresh 1.0.55 “GalleryRefresh”
cordova-plugin-googleplus 5.2.1 “Google SignIn”
cordova-plugin-inappbrowser 2.0.2 “InAppBrowser”
cordova-plugin-ionic-keyboard 2.1.3 “cordova-plugin-ionic-keyboard”
cordova-plugin-ionic-webview 1.2.1 “cordova-plugin-ionic-webview”
cordova-plugin-market 1.2.0 “Market”
cordova-plugin-nativeaudio 3.0.9 “Cordova Native Audio”
cordova-plugin-nativestorage 2.3.2 “NativeStorage”
cordova-plugin-screen-orientation 3.0.1 “Screen Orientation”
cordova-plugin-splashscreen 5.0.2 “Splashscreen”
cordova-plugin-statusbar 2.4.3-dev “StatusBar”
cordova-plugin-tts 0.2.3 “TTS”
cordova-plugin-whitelist 1.3.3 “Whitelist”
cordova-plugin-x-socialsharing 5.4.3 “SocialSharing”
cordova-plugin-x-toast 2.7.2 “Toast”
cordova-replay 0.0.4 “CordovaReplay”
cordova-sqlite-storage 2.6.0 “Cordova sqlite storage plugin”
es6-promise-plugin 4.2.2 “Promise”
ionic-plugin-deeplinks 1.0.17 “Ionic Deeplink Plugin”
onesignal-cordova-plugin 2.4.5 “OneSignal Push Notifications”

Sdk versions -

android:minSdkVersion=“21”
android:targetSdkVersion=“26”

Build Gradle dependencies -

dependencies {
implementation fileTree(dir: ‘libs’, include: ‘*.jar’)
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: “:CordovaLib”))
implementation “com.squareup.okhttp3:okhttp-urlconnection:3.10.0”
implementation “com.android.support:support-v4:24.1.1+”
implementation “com.facebook.android:facebook-android-sdk:4.+”
implementation “com.google.android.gms:play-services-auth:+”
implementation “com.google.android.gms:play-services-identity:+”
implementation “com.onesignal:OneSignal:3.10.3”
implementation “com.google.firebase:firebase-messaging:+”
implementation “com.google.android.gms:play-services-base:+”
implementation “com.android.support:support-v4:28.0.0”
implementation “com.clevertap.android:clevertap-android-sdk:3.4.2”
implementation “com.github.bumptech.glide:glide:4.8.0”
implementation “com.android.support:design:28.0.0”
implementation “com.android.support:appcompat-v7:28.0.0”
// SUB-PROJECT DEPENDENCIES END
}

5 Likes

modify your config.xml and add 2 plugins:

<preference name="android-targetSdkVersion" value="28" />
  <plugin name="cordova-android-support-gradle-release">
      <variable name="ANDROID_SUPPORT_VERSION" value="28.+" />
  </plugin>
  <plugin name="cordova-plugin-ignore-lint-translation" spec="~0.0.1" />

this cordova-plugin-ignore-lint-translation might not be needed if you are not using facebook plugin

1 Like

This worked:

You can use minSdkVersion as 21 as well, need not be 19 though.

1 Like

Thanks @anshuman , this solve my problem.

Hi @kleeb, thank you so much :), solved this error, but now I’m getting another one:

Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

Have you solved this one as well?

ionic cordova plugin add cordova-plugin-androidx 
ionic cordova plugin add cordova-plugin-androidx-adapter
ionic cordova run android --verbose