Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android : Unable to build app #25293

Closed
NweThazin opened this issue Jun 18, 2019 · 65 comments
Closed

Android : Unable to build app #25293

NweThazin opened this issue Jun 18, 2019 · 65 comments
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@NweThazin
Copy link

NweThazin commented Jun 18, 2019

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 for androidx (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:

@NweThazin NweThazin added the Bug label Jun 18, 2019
@react-native-bot react-native-bot added the Platform: Android Android applications. label Jun 18, 2019
@hussainahmad

This comment has been minimized.

@developerashish01

This comment has been minimized.

@developerashish01
Copy link

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

@divyanshupathak94
Copy link

I am facing same issue. screenshot attached.

Environment -
react native - 0.57.8
node - 11.4.0
npm - 6.4.1
OS - windows 10

my build.gradle file -
build.txt

I also follow link mentioned below but no success -
https://github.com/facebook/react-native/commit/8e39451512b6c61e97c44b8c3091d97d62027fec

image

@MR03web

This comment has been minimized.

@internet5

This comment has been minimized.

@divyanshupathak94
Copy link

@MR03web any idea how to resolve this ?

@nyur321
Copy link

nyur321 commented Jun 18, 2019

Same issue. This happened a few hours ago. RN version 0.59.8

@iamiota

This comment has been minimized.

@cosivox

This comment has been minimized.

@nghiant96
Copy link

I am update all dependencies (skip react and react-native). It working for me.

@nodece

This comment has been minimized.

@Deantsui

This comment has been minimized.

@zhllucky

This comment has been minimized.

@Chi-AnTai
Copy link
Contributor

Chi-AnTai commented Jun 18, 2019

I guess the problem is google play service and firebase just released
https://developers.google.com/android/guides/releases

@MR03web
Copy link

MR03web commented Jun 18, 2019

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

yarn upgrade react-native-device-info@2.1.2
cd android && gradlew clean
react-native run-android

It working for me.

@richieroldan
Copy link

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

@nyur321
Copy link

nyur321 commented Jun 18, 2019

@richieroldan cheers mate

@developerashish01
Copy link

after making changes suggested by @richieroldan i am getting another issues

node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:51: error: cannot find symbol

@cosivox
Copy link

cosivox commented Jun 18, 2019

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

How did you upgrade to androidx by refactoring on androis studio or setting

android.useAndroidX=true
android.enableJetifier=true

in gradle.properties ?

@richieroldan
Copy link

after making changes suggested by @richieroldan i am getting another issues

node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:51: error: cannot find symbol

What's in RNFirebaseMessagingService.java:51 ?
sorry I'm not using firebase right now.

@cosivox Both

@matthiasleitner
Copy link

How to solve this without migrating to AndroidX?

@developerashish01
Copy link

@richieroldan yes i am using firebase, it was working very well till yesterday

@TomBallagh
Copy link

TomBallagh commented Jun 18, 2019

@Chi-AnTai referred to this earlier and this is the answer. Just follow steps on google dev website. Confirmed working for us now.

https://developers.google.com/android/guides/releases

Happy building.

@Chi-AnTai
Copy link
Contributor

Chi-AnTai commented Jun 18, 2019

OK, thanks @MR03web

What solve my problem is first upgrade react-native-device-info@2.1.2 follow @MR03web

then change android build.gradle
compileSdkVersion to 28
buildToolsVersion to 28.0.3

change gradle-wrapper.properties
https://services.gradle.org/distributions/gradle-4.4-all.zip to 4.6

upgrade Android Studio and from Android Studio Refator => Migrate to AndroidX (before AS upgrade the migration said my android version is not 28 even though my build.gradle is really 28, after upgrade the AS ask me to configure project and the configuration window said my android version is a variable instead of a real number so I change it to 28 and finally I can migrate)

I am not sure every step is necessary, I just list what I have done and hope this can help someone.

The process is very similar to https://developers.google.com/android/guides/releases, I guess I fail this at first because my Android Studio is not upgrade.

@js7331
Copy link

js7331 commented Jun 18, 2019

@matthiasleitner

How to solve this without migrating to AndroidX?

I fixed it via #25292 (comment)

@nodece
Copy link

nodece commented Jun 18, 2019

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

yarn upgrade react-native-device-info@2.1.2
cd android && gradlew clean
react-native run-android
It working for me.#25293 (comment) !

Thanks https://github.com/MR03web that solved my problem!

Without the need to migrate to AndroidX!

react-native-device-info@0.13.0 use com.google.android.gms:play-services-gcm:+ library triggered my problem.

Update app/build.gradle:

implementation(project(":react-native-device-info"),  {
  exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-gcm:16.0.0"

ENV

React Native version: 0.57.5
Platform : android
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"

@nodece
Copy link

nodece commented Jun 18, 2019

How to solve this without migrating to AndroidX?

See: #25293 (comment)

@mihaidaviddev
Copy link

mihaidaviddev commented Jun 18, 2019

@quarryman the versions are wrong..find out why com.google.firebase:firebase-iid requested version is 19.0.0.. this is the latest version as of yesterdays update.. https://developers.google.com/android/guides/releases

Here you can see the dependencies of firebase-messaging 17.0.0. (firebase-iid 16.0.0)
https://mvnrepository.com/artifact/com.google.firebase/firebase-messaging/17.0.0

@Otik133040040 I would look in every plugin in node_modules android/build.gradle and find if the plugin is using a new version listed in the release note..then I would make the changes suggested by nodece and kelset

I hope it helps..

@mikehardy
Copy link
Contributor

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

@hrachqyutukyan

This comment has been minimized.

@thebusted

This comment has been minimized.

@adnkh

This comment has been minimized.

@thodubois
Copy link

thodubois commented Jun 18, 2019

A better way to fix asap is to fix google dependencies versions.

The issue come from your project dependencies. They may implement google dependencies with a :+.
This lead to add some AndroidX dependencies. Your app can only implement support or androidx. Since new versions are compatible androidx, it create issues.

Search in your node_modules if a package implement things like com.google.android.gms:play-services-gcm:+.

See : https://developers.google.com/android/guides/releases

I use react-native-device-info and react-native-google-analytics-bridge and both check a googlePlayServicesVersion variable for a version.

I add googlePlayServicesVersion = '16.+' in android/build.gradle :

buildscript {
    ext {
        googlePlayServicesVersion = '16.+'

And it works for me.

Is it possible to overwrite some dependencies from the root project?

@hrachqyutukyan

This comment has been minimized.

@witalobenicio

This comment has been minimized.

@calintamas
Copy link

If using zo0r/react-native-push-notification,
specify exact versions in android/build.gradle:

buildscript {
    ext {
        ...
        googlePlayServicesVersion = "16.1.0"
        firebaseVersion = "17.3.4"
       ...
    }
}

@divyanshupathak94

This comment has been minimized.

@azrirhmn

This comment has been minimized.

@vitoraguila

This comment has been minimized.

@hrachqyutukyan
Copy link

hrachqyutukyan commented Jun 18, 2019

try change in your android/build.gradle file

buildscript {
    ext {
        ...
        googlePlayServicesVersion = "16.0.0"
        firebaseVersion = "17.3.4"
       ...
    }
}

@nodece

This comment has been minimized.

@yk-yong

This comment has been minimized.

@witalobenicio

This comment has been minimized.

@witalobenicio

This comment has been minimized.

@hrachqyutukyan

This comment has been minimized.

@nodece

This comment has been minimized.

@witalobenicio

This comment has been minimized.

@nodece

This comment has been minimized.

@nodece

This comment has been minimized.

@witalobenicio

This comment has been minimized.

@nodece

This comment has been minimized.

@bonesyblue
Copy link

@kelset Thanks for the workaround! For anyone else that is still having issues, please pay special attention to kelset's comment above:

you have other libraries (not device-info) that depend on latest, and you need to debug/find out which ones

I had another third-party dependency (react-native-google-analytics-bridge) which specified in its build.gradle file the following: com.google.android.gms:play-services-analytics:+. Taking a look over at the Google Android APIs release notes page, there were breaking updates to the whole com.google.android.gms group of APIs on 17th June 2019. To fix my issue, I added the following to my android/app/build.gradle file:

implementation(project(":react-native-google-analytics-bridge`"),  {
  exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-analytics:16.0.8"

Make sure to check through all your third-party dependency android/build.gradle files and to look in particular for any com.google.android.gms:<API-name>:+ patterns, which will be pulling the latest APIs. Then head over to the Google APIs release notes page and find the latest 16.x.x update, which should hopefully fix any issues.

@kelset
Copy link
Collaborator

kelset commented Jun 18, 2019

Thanks @bonesyblue for the write up, it's way more clear than mine 😅🙇‍♂️

Given that this issue sort of spinned out of control a bit, I'll lock it for now to keep your comment as the one people will land on 👍

@facebook facebook locked as resolved and limited conversation to collaborators Jun 18, 2019
@hramos hramos unpinned this issue Dec 5, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jun 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests