Mahima Jain
Mahima Jain

Reputation: 23

Nativescript build fails with error "Manifest merger failed "

I am trying to debug my Nativescript app using command 'tns debug android' but build process keeps failing. Error stack trace:

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:17:2-42:16 to override.FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':app:processDebugManifest'. 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:17:2-42:16 to override.

Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Get more help at https://help.gradle.org

BUILD FAILED in 15s Unable to apply changes on device: 18d388bb7cf4. Error is: Command gradlew.bat failed with exit code 1.

I have followed the steps described in Nativescript docs to set up my dev environment.

Step 1 : npm install -g nativescript

Step 2 : @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-objectnet.webclient).DownloadString('https://www.nativescript.org/setup/win'))"

Step 3 : npm install

Step 4 : tns debug android

I have tried this and this too but no luck.

I have also tried to remove/uninstall everything including Nativescript, and started from scratch then also it is not working.

Please guide what should I do to resolve the error.

Upvotes: 1

Views: 1195

Answers (2)

Francesco Ferretti
Francesco Ferretti

Reputation: 36

I had the same problem today, I solved with this guide https://www.nativescript.org/blog/support-for-androidx-in-nativescript at section "Q: I'm a NativeScript application developer. How am I affected by this AndroidX migration?"

Follow this steps:

  • npm install tns-core-modules@androidx --save-exact
  • tns platform add android@androidx

Then try to build your project

Upvotes: 2

Rob Lauer
Rob Lauer

Reputation: 3171

The problem is with a plugin you are using. Please see this issue.

The basic issue is with the latest Google Play Services version uses AndroidX, which will cause a build fail with plugins that reference the Google Play Library with + (meaning, take the latest version), instead of referencing a specific version that doesn't use AndroidX.

So the solution is to identify the trouble plugin and create an issue in that plugins GitHub repo to request the author to correct their reference of the Google Play Library.

Upvotes: 2

Related Questions