I am working on my app.Everything was ok but i do not know why i got this error when i tried to run the application:
Execution failed for task ':inteligentestate: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 <application> element at AndroidManifest.xml:6:5-28:19 to override.
from the error suggestion i added tools:replace="android:appComponentFactory" in my main application manifest:
<application
android:name=".application.App"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:appComponentFactory">
When i run my app i got this error:
Task :inteligentestate:processDebugManifest FAILED
/mnt/main/Project/.../AndroidManifest.xml:6:5-29:19 Error:
tools:replace specified at line:6 for attribute android:appComponentFactory, but no new value specified
/mnt/main/Tutorial/Android/project/.../AndroidManifest.xml Error:
Validation failed, exiting
I googled and I found this post .
I'm not using androidX
This is my project dependencies:
dependencies {
// Support
implementation "com.android.support:design:${versions.supportLib}"
implementation "com.android.support:recyclerview-v7:${versions.supportLib}"
implementation "com.android.support:cardview-v7:${versions.supportLib}"
implementation "com.android.support:gridlayout-v7:${versions.supportLib}"
implementation "com.android.support:customtabs:${versions.supportLib}"
// room
implementation "android.arch.persistence.room:runtime:${versions.room}"
annotationProcessor "android.arch.persistence.room:compiler:${versions.room}"
implementation "android.arch.persistence.room:rxjava2:${versions.room}"
// Network
implementation "com.google.code.gson:gson:${versions.gson}"
implementation "com.squareup.retrofit2:retrofit:${versions.retrofit}"
implementation "com.squareup.retrofit2:converter-gson:${versions.retrofit}"
implementation "com.squareup.okhttp3:logging-interceptor:${versions.interceptor}"
//rx java
implementation "io.reactivex.rxjava2:rxandroid:${versions.rxAndroidVersion}"
implementation "io.reactivex.rxjava2:rxjava:${versions.rxJavaVersion}"
//Other
implementation "com.jakewharton.timber:timber:${versions.timber}"
implementation "com.jakewharton:butterknife:${versions.butterknife}"
annotationProcessor "com.jakewharton:butterknife-compiler:${versions.butterknife}"
implementation "com.google.dagger:dagger:${versions.dagger}"
annotationProcessor "com.google.dagger:dagger-compiler:${versions.dagger}"
// Testing
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 project(path: ':map')
}
And library dependancies:
dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
api "com.android.support.constraint:constraint-layout:${versions.constraintLayout}"
api "com.android.support:appcompat-v7:${versions.supportLib}"
api "com.android.support:support-v4:${versions.supportLib}"
// Mapbox
api "com.mapbox.mapboxsdk:mapbox-android-sdk:${versions.mapboxMapSdk}"
api "com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v7:${versions.mapboxPluginLocalization}"
I found this post anber mentioned that
project has different versions of the same library
But i think my project's library is the same!!!
Solution: Android Studio => Refactor Menu => Migrate to AndroidX.
Yes it's easy.
Go to your application manifest and at bottom you'll see mergedManifest option
navigate to mergedManifest bottom where it will tell your what you've error and in what file
See you error closer. It's mostly error in our layout file that's why merged Manifest don't works
Hope so it will solve your error!!!
please try downgrade your gradle version and restart Android studio
Related
I added MaterialAlertDialog to my project which was not using androidx. This caused errors during the next build. So i removed the 'implementation' statement from app level build gradle. But still i am having manifest merge error when i try to build my project.
This is the error i get during build time
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:19:5-152:19 to override.
So far i have tried the following solutions,Close and reload my project. Do a clean and rebuild .delete the .gradle and .idea folders in my project and build it again
These are the dependencies in my project
dependencies
{
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "com.android.support:appcompat-v7:${android_support_version}"
implementation "com.android.support:design:${android_support_version}"
implementation 'com.github.lzyzsd:circleprogress:1.1.0#aar'
implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1#aar'
implementation 'commons-net:commons-net:3.3'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
implementation "de.hdodenhof:circleimageview:${circle_imageview}"
implementation "com.github.bumptech.glide:glide:${glide_version}"
implementation "com.android.support:recyclerview-v7:${android_support_version}"
implementation "com.android.support:cardview-v7:${android_support_version}"
implementation "com.squareup.retrofit2:retrofit:${retrofit_service_version}"
implementation "com.squareup.retrofit2:converter-gson:${retrofit_gson_convertor}"
implementation "com.clough.android.androiddbviewer:androiddbviewer:${dbviewer_version}"
implementation "com.android.support:multidex:${multidex_version}"
implementation "com.github.crosswall:Android-Coverflow:${viewPager_version}"
implementation "com.squareup.okhttp3:logging-interceptor:3.4.0"
implementation project(':sdkui')
implementation 'com.github.ronaldsmartin:Material-ViewPagerIndicator:1.0.4'
implementation 'com.google.android.gms:play-services-base:16.0.1'
implementation 'com.google.android.gms:play-services-identity:16.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-auth-api-phone:16.0.0'
implementation 'com.google.firebase:firebase-config:16.1.0'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
}
apply plugin: 'com.google.gms.google-services'
I am answering this just to specify the step it took to clear my issue.
I removed the gradle dependency for the MaterialDesign.
The cashe issue was solved by doing File-> Invalidate Cache & restart
Since Firebase was changed to ver 20 before restart the issue persisted.
Reduced Firebase version to 17.3.4 this fixed everything.
Add these lines in your Manifest file.
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
Manifest File
<application
android:allowBackup="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="false"
android:theme="#style/AppTheme"
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString">
Try this
With Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.
If you have any Maven dependencies that have not been migrated to the AndroidX namespace, the Android Studio build system also migrates those dependencies for you when you set the following two flags to true in your gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
Add these lines in your Manifest file in Application TAG.
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
This question already has an answer here:
play-services-ads conflicts with appcompat
(1 answer)
Closed 3 years ago.
Iv have an immediate conflict on an empty project once I implement gplay services.
On the latest android studio on mac, i create a simple activity app:
mainactivity:
package semy.apps.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
then once i add implementation 'com.google.android.gms:play-services-ads:18.1.1' on build.gradle
dependencies {
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'
implementation 'com.google.android.gms:play-services-ads:18.1.1'
}
i get
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:5:5-19:19 to override.
i try to add those tags on manifest to no avail, still doesnt work
A quick solution to your problem could be to add the following 3 lines in your AndroidMannifest.xml
xmlns:tools="http://schemas.android.com/tools"
tools:replace="android:appComponentFactory"
android:appComponentFactory="#string/app_name"
So, after adding the above 3 lines your AndroidMannifest.xml should look like,
AndroidMannifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
<!--Add the following 3 lines-->
<application
xmlns:tools="http://schemas.android.com/tools"
tools:replace="android:appComponentFactory"
android:appComponentFactory="#string/app_name"
...
>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</application>
</manifest>
EDIT: Update your dependencies to the latest version as play-services-ads is using androidx version of support library and you are using the traditional one.
build.gradle (Module: app)
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout: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'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
}
I hope it will fix your build error. Let me know if it works?
I added this to my project:
implementation 'com.google.firebase:firebase-messaging:19.0.0'
and result:
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:15:5-71:19 to override.
So I go went ahead and added that line to the manifest, and I get this:
Manifest merger failed with multiple errors, see logs
I went to merging errors, and I see this now:
Error: tools:replace specified at line:15 for attribute android:appComponentFactory, but no new value specified app main manifest (this file), line 14
Here are my current gradle dependencies:
dependencies {
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'
implementation project(path: ':bluefire-api-v25.5')
implementation "com.jakewharton:butterknife:8.5.1"
annotationProcessor "com.jakewharton:butterknife-compiler:8.8.1"
implementation 'com.myhexaville:smart-image-picker:1.0.4'
implementation 'com.github.gcacace:signature-pad:1.2.1'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-messaging:19.0.0'
}
I hit a dead-end. Thoughts?
To troubleshoot your problem, Follow below steps:
Open your AndroidManifest.xml
There is a tab on the bottom of the Ide named "Merged Manifest". Open it.
This will list out the Merged Manifest at the left and their sources
at right.
As you are facing
Manifest "merger failed" error, you will see Some Merging Errors.
This will tell you exactly which part is in conflict. Resolve that
and you are done.
In your case, the error is because of the conflict between different support libraries. i.e. between androidx and older support lib. Migrate all your support library to AndroidX. The latest firebase library you are using is already migrated from the Android Support Libraries to the Jetpack (AndroidX) Libraries.
This post will help you to migrate to AndroidX : Migrating to AndroidX
This Issue occur due to support and andoidx library both present.
Check Firebase Release Note.
This release is a MAJOR version update and includes breaking changes.
With this release, libraries are migrated from the Android Support
Libraries to the Jetpack (AndroidX) Libraries. The updated libraries
will not work unless you make the following changes in your app:
Upgrade com.android.tools.build:gradle to v3.2.1 or later. Upgrade
compileSdkVersion to 28 or later. Update your app to use Jetpack
(AndroidX); follow the instructions in Migrating to AndroidX.
If you have used support version in your gradle, than down firebase version to 18.0.0. Otherwise you need to migrate to androidx.
I also got the same issue last day. After downgrading 'com.google.firebase:firebase-messaging:19.0.0' to 'com.google.firebase:firebase-messaging:18.0.0', it is fixed
Add this to your application tag in your manifest:
'tools:replace="android:appComponentFactory"
and go to merger manifest in manifest file to check what the problem is.
change your library to-:
'com.google.firebase:firebase-messaging:18.0.0'
When I'm building Gradle with androidx I get the following error. Please help me to solve this issue.
Error Message: 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).
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.kanwarpreet.dealmybook">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".activities.SplashActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.LoginActivity" />
<activity android:name=".activities.RegisterActivity" />
<activity
android:name=".activities.HomeActivity"
android:label="#string/title_activity_home"
android:theme="#style/AppTheme.NoActionBar" />
<activity
android:name=".activities.BookDetailsActivity"
android:label="#string/title_activity_book_details"
android:theme="#style/AppTheme.NoActionBar"/>
<activity android:name=".activities.AddBookActivity" />
</application>
</manifest>
Build.Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.kanwarpreet.dealmybook"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
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'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
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'
}
Put these flags in your gradle.properties
android.enableJetifier=true
android.useAndroidX=true
After hours of struggling, I solved it by including the following within app/build.gradle:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Put these flags in your gradle.properties
android.enableJetifier=true
android.useAndroidX=true
Changes in build.gradle:
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha04'
Refer to: https://developer.android.com/jetpack/androidx/migrate
Reason of this error-
Because after upgrade, androidx.core:core is accessed somewhere, when your project is still not using androidx. So classes like CoreComponentFactory and many others are now found at two places - androidx.core:core and com.android.support:support-compat. That's why this error occured.
What is solution?
You should migrate to AndroidX. If you don't know about AndroidX. Please read What is AndroidX?
How to migrate your project
After Android Studio 3.2 (September 2018), there is direct option to migrate existing project to AndroidX. This refract all packages automatically.
Before you migrate, it is strongly recommended to backup your project.
Existing project
Android Studio > Refactor Menu > Migrate to AndroidX...
It will analysis and will open Refractor window in bottom. Accept changes to be done.
New project
Put these flags in your gradle.properties
android.enableJetifier=true
android.useAndroidX=true
Check #Library mappings for equal AndroidX package.
Check #Official page of Migrate to AndroidX
Error explicitly says-
[com.android.support:support-compat:28.0.0]
AndroidManifest.xml:22:18-91 is also present at
[androidx.core:core:1.0.0]
AndroidX is the latest support library from Google. It contains all previous components from all older appcompat versions. Do NOT use appcompat-v-any number. Instead, use a similar component from AndroidX libraries. Remove the numbered support libraries from your Gradle and your code wherever it is imported. Then sync your gradle.
Component similarity table can be found here. Also, follow the steps mentioned in Migrating to AndroidX.
Again, stop using any previous appcompat numbered versions. There's only AndroidX now.
Hope this helps.
you have to move on the Androidx because your project is using some feature
from there.so you need to migrate to AndroidX
follow these snippets
look at this second snippet
One suggestion to find out the exact reason is to open the manifest file and in bottom you will see a Merge Manifest option where you will see exact reason for failure.
See below image
Just add a line into gradle.properties
android.enableJetifier=true
android.useAndroidX=true
Project-wide Gradle settings.
IDE (e.g. Android Studio) users:
Gradle settings configured through the IDE will override any settings specified in this file. For more details on how to configure your build environment visit http://www.gradle.org/docs/current/userguide/build_environment.html
Specifies the JVM arguments used for the daemon process. The setting is particularly useful for tweaking memory settings
org.gradle.jvmargs=-Xmx1536m
android.enableJetifier=true
android.useAndroidX=true
When configured, Gradle will run in incubating parallel mode. This option should only be used with decoupled projects. More details, visit http://www.gradle.org/docs/current/userguide/multi_project_builds.html
sec:decoupled_projectsvorg.gradle.parallel=true
I also faced this problem because I was using some external library in my project and one of them was not converted into AndroidX.
add below code to android/build.gradle under buildscript ext
googlePlayServicesVersion = "16.0.0"
googlePlayServicesVisionVersion = "17.0.2"
and below code to gradle.properties
android.enableJetifier=true
android.useAndroidX=true
I let Android Studio convert my Relative layout views to Constraint layout. So Android Studio added one of the com.andriod.support... while I added the androidx... dependency when I removed the second one the error was gone.
dependencies {
implementation "androidx.constraintlayout:constraintlayout:2.1.0"
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
}
This was my error:
Manifest merger failed : Attribute application#appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.3.2] AndroidManifest.xml:24:18-86
is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:3-26:17 to override.
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:one.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
In manifest add tools:replace="android:theme" to your application
I have resolve problem by removing
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
from app build.gradle and using
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha04'
instead of it.
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.
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:
Use a lower version for ButterKnife.
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.
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.
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.