How to find which library use AndroidX - [Resolved] - android

I'm using react native and my Android project isn't compiling anymore because of 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:28:5-109:19 to override.
I've tried to add that tag but I'm getting always errors!!
I've tried to remove all packages to find which had androidX support or how to fix this bug, but I've been stuck for days!
Thanks!
UPDATE
I've opened all gradle files of the libraries and one at the time I've checked the dependencies, excluding or changing the version of some.
A terrible work but now I'm able to compile...
Thanks to all!

This is probably related to a Google update on the google place services. You can find which library is using AndroidX with this command:
gradlew app:dependencies
App is the name of your module/project but that is usually the default one.
If you can't solve this this way, post your project and app build.gradle

Make sure that you import the right version for AndroidX from here: https://developer.android.com/jetpack/androidx/migrate
I got stuck one day also just because integrate wrong version. So check it just to be sure.

Related

Manifest merger failed - Don't want to migrate to androidx

I don't want to migrate to androidx. what can I do???
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.1.0] AndroidManifest.xml:24:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:25:5-120:19 to override.
Not migrating to Androidx will be delimiting to you in the future. If you are sure that your application will not use new APIs or Libraries in the future, then feel free to stick with the Android nomenclature. But if you are not certain, then going through the painful process is worth it.
There are documentations that help you to perform this HUGE migration, basically by using incremental approach. Feel free to refer to this document and follow it religiously, by performing small increements.
Blogs
Androidx official documentation
Cross stitching android and Androidx
Migrating to Androidx Tips
Video guides
Androidx Video Guide

Dagger and Butterknife

I am using dagger2 in my app. But when I started project my activities was extended support AppcompatActivity.Now while build I am getting warning via butterknife.
API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
To fix this I must upgrade butterknife version from 9.0.0-rc1 to 10.2.0 when I change version butterknife to 10.2.0 I am getting error to build.Because I am not using androidx. error like this:
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:9:5-70:19 to override.
So I don't know how to fix this issue.If somebody had such kind of error and warning please help me if you fixed it
Migrate your project to AndroidX, butterknife 10.2.0 is on androidX.
It literally says what you need to do. Add tools:replace="android:appComponentFactory" like this: <application tools:replace="android:appComponentFactory"

AndroidManifest error related to AndroidX when trying to build React Native 0.59 app

I'm trying to build a React Native Android application following an upgrade to RN 0.59.9, but I'm getting an error related to AndroidX.
I've tried many things including removing most native packages, changing AndroidManifest.xml and various other solutions mentioned on the internet but nothing seems to work.
My error is this:
> Task :app:processReleaseManifest FAILED
....\android\app\src\main\AndroidManifest.xml:22:18-91 Error:
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:35:2-108:16 to override.
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
FAILURE: Build failed with an exception.
As I understand it means one of the package uses AndroidX but not the main app, however as far as I can tell nothing in my app uses AndroidX, and I made sure to upgrade to RN 0.59, not 0.60. I've even tried to grep "androidx" and remove all the packages that might mention it.
I've also tried to add "android.useAndroidX=true / android.enableJetifier=true" to gradle.properties just to see what happens but as expected many modules don't build since they have not been upgraded to AndroidX.
Any idea how to fix this bug?
This is most likely due to Android releasing all AndroidX libraries, and '+'-style gradle dependencies leaking in.
You can either ./gradlew :app:dependencies|grep androidx to find the problem libraries and then use gradle resolutionStrategies or android/build.gradle ext{} versioning to pin the Google library dependency, or you can convert your react-native project to androidx and use the jetifier tool via npm i jetifier && npx jetify so that non-androidx react-native libraries work.
Either should result in a working build as the react-native ecosystem transitions to AndroidX

Manifest merger failed when using leakcanary 2.0 alpha 2

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:
A project using androidx can use a library that uses android.support
But a project using android.support can not use a library that uses androidx
This SO answer explain androidx and how to migrate your project to androidx.

React native "Execution failed for task: ':app:processDebugManifest' after adding Admob module

Working with a React Native project and ready for release but running into this error:
Execution failed for task ':app: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:7:5-117 to override.
Works fine before adding the "react-native-admob" module through npm using "npm i --save react-native-admob#next"
In order to complete the project I need admob running! help please!
You are having this issue because your dependencies are depending on android support libaries. some have the older version named eg. 'com.android.support..', while some depend on the newer androidX library with names 'androidx.core....'. Having both com.android.support and androidx libaries in the same project will prevent the app from building.
This issue likely arose from the June 17 update to google play services which included major breaking changes to android support libraries. https://developers.google.com/android/guides/releases.
To fix this issue, identify all yr react-native packages and check if they have dependencies (listed under the play services release notes) that have been forceably updated to the newest version which gives androidx. If you have the android folder in the project that holds your build.gradles, try cd android, and then run ./gradlew app:dependencies --scan. This generates a unique link to a report for you to inspect each packages' dependencies. Expand your dependencies and make sure react-native packages when fully expanded do not contain any androidx file. Check all paths, testCompileClasspath, testRuntimeClassPath....
If you do have affected dependencies, you will need to force those packages to use the older version with com.android.support. This issue link has several suggestions on how to implement. https://github.com/facebook/react-native/issues/25292
I fixed this issue happening with our builds couple days back by doing stuff similar to this in my app/build.gradle:
implementation(project(':react-native-camera')){
exclude group: 'com.google.android.gms'
}
You might also need to declare some top-level configuration to force google play service and firebase to use specific version.
The official documention on androidx recommends people to switch to using the newer library androidx, and tell you to enable androidX and Jettifier to true. This DOES NOT work 100% for react-native libraries. So don't upgrade packages to androidx until you are sure all dependencies you have in your project are eligible for the migration to androidx.

Categories

Resources