0
dependencies {
    implementation 'com.jakewharton:butterknife:10.0.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'

}

These are the dependencies, in build.gradle

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:7:5-21:19 to override.

I wished to add a library to my project, it is called as ButterKnife library, before adding this library the project was fine, but as I added this library. Manifest merger failed error occurred.

What I have tried? I added these lines to my AndroidManifest.xml:

tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"

But this generated another set of errors

Caused by: com.android.tools.r8.utils.AbortException: Error: Static interface methods are only supported starting with Android N (--min-api 24): void butterknife.Unbinder.lambda$static$0()

I tried removing butterknife library, and then it builds finely.

I also tried adding only one of those lines:

tools:replace="android:appComponentFactory"

This did nothing and produced yet another error:

Manifest merger failed with multiple errors, see logs

I tried Refractor->migrate to androidx, this created a new problem in Java file, which now says that it "cannot resolve symbol R"

So what should I do, I am following some course online for app development. And the person teaching this course does not seem to have these errors.

rishabh jain
  • 108
  • 1
  • 8

3 Answers3

3

com.jakewharton:butterknife:10.0.0 is using AndroidX. Check it here.

But you also depend on com.android.support:appcompat-v7:28.0.0.

You shouldn't mix dependencies using AndroidX with non-AndroidX.

You have two options:

  1. Use a lower version for ButterKnife.
  2. Migrate to AndroidX.

To migrate to AndroidX:

Use androidx.appcompat:appcompat:1.0.0 instead of com.android.support:appcompat-v7:28.0.0.

Add the following to your gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

Change imports of your Activity's AppCompatActivity from

import android.support.v7.app.AppCompatActivity;

to

import androidx.appcompat.app.AppCompatActivity;

Check the migration guide here.

aesher9o1
  • 35
  • 1
  • 8
fernandospr
  • 2,976
  • 2
  • 22
  • 43
1

Issue

I think there is something wrong in the current version (latest) of butterknife. The simplest solution that I found for this problem is that change the version that butterknife applies to.

One possible solution

I changed this

implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'

to this

   implementation 'com.jakewharton:butterknife:7.0.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:7.0.1'

Why do this?

What we have done is that we now are going to use the older version of butterknife, the version which works.

rishabh jain
  • 108
  • 1
  • 8
0

I faced the same issue when i tried to apply the butterknife to one of my existing Application.

Application without any AndroidX implementations on your gradle file

implementation 'com.jakewharton:butterknife:7.0.1'
annotationProcessor'com.jakewharton:butterknife-compiler:7.0.1'

this is will work fine.

As the Latest version of the Butterknife uses the AndroidX your project should also be migrated to AndroidX which seems to be extra work if you want on existing project. If the new project with the AndroidX implementation then you can go to the Latest versions:

implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'

if you are willing to migrate your old application to AndroidX please go through the link.

Sunil KV
  • 763
  • 9
  • 13