0

I have this in my build.gradle(module:app) :

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint- 
                    layout:1.1.3'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.google.firebase:firebase-database:16.0.4'
                    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso- 
                               core:3.0.2'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:gridlayout-v7:28.0.0'
}

and when I try to sync it displays this:

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.0] 
AndroidManifest.xml:22:18-86 value= 
(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to 
<application> element at AndroidManifest.xml:9:5-32:19 to override.

what can cause this and how do I fix it?

(adding tools:replace="android:appComponentFactory" to the manifest doesn't work)

1 Answers1

1

Your android-image-cropper library is using androidx, while you haven't migrated yet. It is highly recommended to migrate to using Androidx, since most of the libraries are doing the same and may not provide backward compatibility to the com.android.support variants.

If you cannot migrate in the short term, then you can revert to a lower version of the library. As per the changelog, they migrated to AndroidX in 2.8.0, so you should go back to 2.7.0.

shriakhilc
  • 2,922
  • 2
  • 12
  • 17
  • I've tried downgrading to version 2.7.0 and even deleting the library altogether (I haven't used it yet) and it still gave me an error : ERROR: Failed to resolve: com.android.support:appcompat:28.0.0 – Reuven Guetta Jun 17 '19 at 11:03
  • Try generating a dependency tree using gradle ( some methods mentioned [here](https://stackoverflow.com/a/35235229/6698642) ), and check if any of the other libraries also use androidx. If they do, it will clash with your support libraries. – shriakhilc Jun 17 '19 at 11:05
  • 1
    migrating to androidx should solve all problems right?for some reason pressing refractor>migrate to androidx... does nothing – Reuven Guetta Jun 17 '19 at 11:17
  • It should solve them. Follow the migration guide I've linked, and keep in mind that their automated solution is not perfect, so you might have to manually change some things. You should be able to find a number of resources on how to do so online (including other questions on SO) – shriakhilc Jun 17 '19 at 11:38