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.
Related
I have some problem when integrating react-native-google-signin into native android code. I use react-native 0.59.8 and i can't upgrade to 0.60 so far. Therefore I followed an instruction for older react-native-google-signin version which is 2.1.1. Unfortunately it's not working for me. It gives me some errors concerning androidX but as far as I know react-native-google-signin started using androidX from version 3.0.0 upwards, but i use 2.1.1 version which should not use androidX.
Description
The problem starts in sync proccess in Android Studio which gives me the following error:
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:7:5-117 to override.
Now when I'm trying to build my project in Android Studio it gives me another error:
error: package android.support.v4.net does not exist
Interesingly, now problem concerns the package #react-native-community/netinfo which was working fine before I linked react-native-google-signin into my project. I would be very grateful if someone told me what's going on.
EDIT:
My dependencies section from android/app/build.gradle is as follows:
dependencies {
implementation project(':react-native-google-signin')
implementation project(':react-native-reanimated')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-firebase')
implementation project(':react-native-community-netinfo')
implementation project(':react-native-orientation')
implementation project(':react-native-keychain')
implementation project(':react-native-view-shot')
implementation project(':react-native-video')
implementation project(':react-native-fs')
implementation project(':react-native-blur')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation 'com.facebook.react:react-native:+'
implementation 'com.android.support:design:27.1.1'
implementation project(':react-native-navigation')
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation "com.google.firebase:firebase-messaging:17.5.0"
}
Please try the following:
Open your /android/app/build.gradle File, and check your dependencies.
Search for any instance of play-services of firebase, and see for two things:
the line starts with implements (instead of compile)
see if there are any get latest Version wildcard (that is the +-Sign) on it. (Example: implementation "com.google.android.gms:play-services-base:+"
(If you don't found any component implemented with +-Sign, go on further down from topic "GO-ON-HERE" โ in this answer.)
Get those (in my example it is com.google.android.gms:play-services-base and search for it on MVNRepository to get an overview of available Versions.
Here you might choose the newest one, or one that definitely work with your used components and force your App to use it, by updating /android/app/build.gradle like this:
implementation ("com.google.android.gms:play-services-base:17.1.0"){ force = true }
(Note: I don't know, if it's play-services-base in your case, it's only an example)
โ GO-ON-HERE
After that, switch to /android and run ./gradlew :app:dependencies. This regenerate your dependency-tree for your Project.
Open the created Text-file and search for your updated Component:com.google.android.gms:play-services-base to see, where the component will be used.
You might find, that still some components use the +-Sign (com.google.android.gms:play-services-base:+) in the dependency. To fix your issue, you need to patch them (maybe use patch-package to simplify this process) to also use the Version for your component (in our example "play-services-base") you've choosed above.
Hope that helps you out.
I have a relatively new project that I'm trying to build. Gradle syncs fine, but whenever I try to build, I get an error like this:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
> Failed to transform artifact 'common.jar (com.android.tools:common:26.4.0)' to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime-jars}.
> Execution failed for JetifyTransform: C:\Users\Dave\.gradle\caches\modules-2\files-2.1\com.android.tools\common\26.4.0\539939e284fba9fe343b890a6e21c9333767c886\common-26.4.0.jar.
> Failed to transform 'C:\Users\Dave\.gradle\caches\modules-2\files-2.1\com.android.tools\common\26.4.0\539939e284fba9fe343b890a6e21c9333767c886\common-26.4.0.jar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)
> Failed to transform artifact 'bundletool.jar (com.android.tools.build:bundletool:0.7.2)' to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime-jars}.
> Execution failed for JetifyTransform: C:\Users\Dave\.gradle\caches\modules-2\files-2.1\com.android.tools.build\bundletool\0.7.2\31f71b66edcbe41de0268e14c961a7799a03d42a\bundletool-0.7.2.jar.
> Failed to transform 'C:\Users\Dave\.gradle\caches\modules-2\files-2.1\com.android.tools.build\bundletool\0.7.2\31f71b66edcbe41de0268e14c961a7799a03d42a\bundletool-0.7.2.jar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)
I only started this project a week ago, and have been using the stable branch of Android Studio and using Gradle plugin 3.5. So, anyone have any ideas how to fix this?
What I've tried:
Disabling Jetifier in gradle.properties left me with errors about old and new databinding dependencies.
Rolling back to Gradle plugin 3.4.2 gave the same error as above.
Adding android.jetifier.blacklist = pass to gradle.properties left me with the same errors as above.
Adding android.databinding.enableV2=true to gradle.properties left me with the same errors as above.
Running the "Migrate to AndroidX" refactor in Android Studio actually left me with this weird refactor preview:
Removing apply plugin: 'kotlin-kapt' from my app-level build.gradle left me with the same errors as above.
Cleaning and rebuilding doesn't work.
Invalidating and restarting doesn't work.
EDIT 1: Gradle dependencies, for the curious... I don't think I'm using anything particularly weird here.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//Kotlin stuff
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0"
//Test tools
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//UI
implementation 'com.google.android.material:material:1.1.0-alpha10'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.activity:activity:1.1.0-alpha03'
//Lifecycle
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-alpha04'
//Moshi for serialization
implementation 'com.squareup.moshi:moshi:1.8.0'
implementation 'com.squareup.moshi:moshi-kotlin:1.8.0'
//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-moshi:2.6.1'
//Glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.9.0'
//Navigation
implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0'
implementation 'androidx.navigation:navigation-common-ktx:2.1.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.1.0'
implementation "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0"
//Diff utils
implementation group: 'io.github.java-diff-utils', name: 'java-diff-utils', version: '4.0'
//Timber for logging
implementation 'com.jakewharton.timber:timber:4.7.1'
}
Edit 2: Copy-pasted my Gradle dependencies into a new empty project and got the same errors. Could it be one of these dependencies?
Edit 3: Commenting out various libraries from my build.gradle (Moshi, Retrofit, Timber, Glide) also had no effect. So, I probably should submit a bug report to Google. Until then, what's the workaround?
Edit 4: With suggestions from the comments, I tried deleting my .gradle folder and rolling back to an earlier version of the Material design library. Both had no effect, but the latter added something interesting to the build log:
> Transform artifact kotlin-build-common.jar (org.jetbrains.kotlin:kotlin-build-common:1.3.20) with DexingNoClasspathTransform
AGPBI: {"kind":"error","text":"Invoke-customs are only supported starting with Android O (--min-api 26)","sources":[{}],"tool":"D8"}
You are not supposed to put the androidx.navigation:navigation-safe-args-gradle-plugin in your app level build.gradle. That needed to be removed.
Invoke-customs are only supported starting with Android O (--min-api 26).
This means, you'd need at least:
compileSdkVersion 26
targetSdkVersion 26
In my case i updated android studio, automatically it updated my gradle version and the build faled, returning the old version solved the problema.
I'm try to use this button style this link But I had Implementation error, my build.gradle like that:
That's my dependencies :
dependencies {
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.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-database:16.1.0'
implementation 'com.google.firebase:firebase-storage:16.1.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.android.volley:volley:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test๐1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
And the error:
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 element at AndroidManifest.xml:5:5-19:19 to override.
How can I fix that?
I guess this error is happening because their latest version is using AndroidX but your app is still using Support Library.
So, I guess there are two possibilities:
Downgrade library version
Checking their release history, it seems the AndroidX was introduced on version v2.0.0. So, use an old version: v.1.14.0. Just use implementation 'br.com.simplepass:loading-button-android:1.14.0'
Migrate to AndroidX.
You may also consider to migrate to Android X since Android Support library is now deprecated. For any case, you may want to check first solution to ensure the problem is really being caused by the AndroidSupport/AndroidX conflict
Edit
Just sharing more info since you are not aware about the AndroidX.
When developing an Android App, you probably want to build a single APK which works in different Android Versions. However, as you may imagine, there are some differences between different Android versions such as methods that are no longer used (deprecated) or were added later etc. Features that exists in a version but not in others etc.
For this reason, you will end up using the Android Support Library.
It is a special library which helps you to support several Android versions. Not only that, but some views such as ConstraintLayout, RecyclerView and CardView were released as a library.. as part of the Android Support Library.
In your build gradle, we can see that you are already using the Android Support Library:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
However, on last year, Android deprecated the Support Library and created the AndroidX. In a certain way, it is the same thing.. Just a different name..
Sooner or later, you will migrate your app to Android X since support library won't be updated anymore.
However, not only you app will migrate to AndroidX but some third party library will move to AndroidX as well. In this case, we have the library LoadingButtonAndroid that started to used the android X in version v.2.0.0. However, since you didn't migrate your app yet, you have some this kind of conflit. So, you fix by either using an old version of LoadingButtonAndroid or by migrating your app to AndroidX.
HERE you can find how to migrate your app to AndroidX. Usually, it is a very simple process. However, Android Studio always forget to change some import and you have to manually change from support library to androidx.
Automatically or manually, migrating to AndroidX just means that you have to update your imports from android.support.v7.app.AppCompatActivity to androidx.appcompat.app.AppCompatActivity
As you can see, class name is the same and there's no code changes... All the views are the same.. Just their package (import) that is different.
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'
Why am I getting this error? My repository and Google play services are up to date and I've used all the requires steps for using Firebase like copying firebase code in both build.gradle(Project and app). The intellisence doesn't even show FirebaseAuth but displays other members of Firebase.
Solved the error by adding this to the build.gradle file(for app) -
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
The 2nd dependency is to solve the version conflict error.
Add this dependency to Gradle.Build(Module:App)
compile "com.google.firebase:firebase-auth:9.0.2"
then sync with gradle :)
Add these two dependencies into your build.gradle
as 'compile' is replaced by 'implementation'
dependencies {
implementation 'com.google.firebase:firebase-auth:16.0.4'
implementation "com.google.android.gms:play-services-gcm:16.0.0"
}
***For the latest android studio version 3.0 and new ones ***
Same problem. Clean your project with "Build"->"Clean Project".
add the following to the build.gradle (app)
implementation 'com.google.firebase:firebase-auth:9.2.1'
For me this worked with all the firebase extensions:
eg.:
Android studio adds the following line to your gradle file:
implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
You have to change it to:
implementation 'com.google.firebase:firebase-auth:16.0.1'
and add:
kapt 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
I have android studio 3.3.1 installed. Compile is replaced with implementation. So you have to write
implementation 'com.google.firebase:firebase-auth:16.1.0'
You should replace version according to the warning you get.
on dependencies in app gradle
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
this is useful android 3.0 and onwards versions auth:16.0.1 and
core:16.0.1Firebase will work
Solved the error by adding this to the build.gradle file(for app) -
compile 'com.google.firebase:firebase-auth:9.2.1'
compile "com.google.android.gms:play-services-gcm:9.2.1"
You may need to make sure that your activity is importing the Firebase Auth module. In your .java file (eg. Login.java):
import com.google.firebase.auth.FirebaseAuth;
Please add the below line in your build.gradle file:
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation "com.google.android.gms:play-services-gcm:10.2.1"
In my case, I was using firebase-auth and firebase-messaging with different versions. So After getting an error I kept the same version for both e.g.
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
After sync, my problem was solved. try to keep the version the same for firebase libraries
implementation 'com.google.firebase:firebase-auth:16.0.1'
make sure your firebase and all the dependency are the same versions.