react-native: Android : Unable to build app
EDIT by @kelset:
TL;DR:
- Google released a new Major version of their Google Play services and Firebase
- this new version has BREAKING CHANGES (release notes)
- some third-party libraries used in react-native projects have loose dependencies on said services, most likely in the
:+
form in their gradle configuration - this is causing Gradle buils to fail because of those BC mentioned above
- to fix, you need to set the dependency to a precise version instead of the
:+
- you can find out which libraries are “pulling in” this new version by running
gradlew app:dependencies
and searching the output forandroidx
(more details here)
Please refer to this comment (and the follow ups) for more details on how to fix - in particular, for debugging, read this comment.
React Native version: 0.58.0 Platform : android
Here are android version: buildToolsVersion = “27.0.3” minSdkVersion = 19 compileSdkVersion = 26 targetSdkVersion = 26 supportLibVersion = “26.1.0”
Building app on android before today is working fine. and suddenly got this issue in android manifest file …\android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:46: AAPT: No resource identifier found for attribute ‘appComponentFactory’ in package ‘android’
Steps To Reproduce
Describe what you expected to happen:
Snack, code example, or link to a repository:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 31
- Comments: 65 (3 by maintainers)
hey @nodece thanks for the investigation, that seems to be the root cause!
It seems that google released a new version of their Play Services, and in particular
com.google.android.gms:play-services-gcm
- so if you are depending on latest (via something likecom.google.android.gms:play-services-gcm:+
) then you need to change it to instead rely on the previous version, in the example16.0.0
.So you may have to do something like
I’m going to close this, as it seems to be caused by third-party libraries and not react native per-se - if something else pops up please comment ahead!
EDIT: if you are still experiencing the issue, it’s likely one of these two reasons:
./gradlew cleanBuildCache
&./gradlew clean
from the /android folderIf it’s neither because of these, please provide a repro so that it can be investigated.
update: The root cause is related to androidx, google play service… try upgrade project to androidx
This problem seems to be triggered by the version of react-native-device-info? 2.1.2 constrain play services dependency to pre-AndroidX 16.1.0 react-native-device-info
It working for me.
How to solve this without migrating to AndroidX?
Thanks https://github.com/MR03web that solved my problem!
Without the need to migrate to AndroidX!
react-native-device-info@0.13.0
usecom.google.android.gms:play-services-gcm:+
library triggered my problem.Update
app/build.gradle
:ENV
As the current maintainer of react-native-device-info we did have a loose (‘+’) dependency in our build.gradle, but it also checked if you specified a version in android/build.gradle first. You should ALWAYS specify your versions like that in android/build.gradle so that you are not subject to 3rd party module defaults (which may either be loose (‘+’) or just some incompatible version.
Hope everyone gets their gradle files sorted out and has successful builds today
Nothing seems to work to me. Tried all above and none worked.
This works for me.
Upgrade your project to androidx https://developer.android.com/jetpack/androidx/migrate
And you need to update your dependencies to androidx as well.
Here’s a gist to update all dependencies automatically to androidx https://gist.github.com/janicduplessis/df9b5e3c2b2e23bbae713255bdb99f3c
I guess the problem is google play service and firebase just released https://developers.google.com/android/guides/releases
@kelset I follow the same steps but no success. I still getting same error.
@Otik133040040 Use the previous versions as suggested…I did the following changes:
Same problem introduced by latest firebase (see https://firebase.google.com/support/release-notes/android#update_-_june_17_2019)
I ended up using previous version as a workaround
react-native-push-notifications library allows to set these versions in gradle.properties as
In other cases you may need exclude from above
com.android.build.api.transform.TransformException: Error while generating the main dex list: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy
i am getting same issue
It working for me after upgrade
react-native-device-info
to2.1.2