1

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.

Mahima Jain
  • 23
  • 1
  • 6
  • I guess it's something with your support libraries, try updating them to latest. – Manoj Jun 20 '19 at 14:06
  • POssibly related to Google Play Services breaking change (from 17th June https://developers.google.com/android/guides/releases) See Rob's answer and the linked issue for a solution. – Nick Iliev Jun 21 '19 at 06:54

2 Answers2

2

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.

Rob Lauer
  • 3,075
  • 1
  • 32
  • 44
2

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

  • The above would need `next` CLI (ver.6) and would work only if you are not using plugins that depend on the Android Support library. With NativeScript 6.x.x we will migrate to AndroidX and will prompt all the plugins to publish AndroidX compatible version (where needed) but until then see the issue linked in Rob's answers for a solution. – Nick Iliev Jun 21 '19 at 06:53