I am using leakcanary 1.6.3
in my project to find memory-leaks without any problem using:
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
Now I want to update it to leakcanary 2.0 alpha 2
using:
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-2
But when I try to build project, it gives me manifest merger failed
.
ERROR: 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.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:10:5-50:19 to override.
How do I fix this error?
Update: I am using android.support
libraries in my project.
After some research in leakcanary 2.0 alpha 2
code, I found that the new version of library uses androidx
libraries but I am using android.support
libraries in my project. If I refactor my project to use androidx
then no error occur.
It seems that:
androidx
can use a library that uses android.support
android.support
can not use a library that uses androidx
This SO answer explain androidx
and how to migrate your project to androidx
.