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

Comments

@NweThazin
Copy link

@NweThazin 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:

@hussainahmad

This comment was marked as spam.

Copy link

@hussainahmad hussainahmad commented Jun 18, 2019

getting same issue

@developerashish01

This comment was marked as spam.

Copy link

@developerashish01 developerashish01 commented Jun 18, 2019

i am getting same issue

@developerashish01

This comment has been minimized.

Copy link

@developerashish01 developerashish01 commented Jun 18, 2019

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

This comment has been minimized.

Copy link

@divyanshupathak94 divyanshupathak94 commented Jun 18, 2019

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 was marked as spam.

Copy link

@MR03web MR03web commented Jun 18, 2019

getting same issue...

@internet5

This comment was marked as resolved.

Copy link

@internet5 internet5 commented Jun 18, 2019

how to resovle it?

@divyanshupathak94

This comment has been minimized.

Copy link

@divyanshupathak94 divyanshupathak94 commented Jun 18, 2019

@MR03web any idea how to resolve this ?

@nyur321

This comment has been minimized.

Copy link

@nyur321 nyur321 commented Jun 18, 2019

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

@iamiota

This comment was marked as spam.

Copy link

@iamiota iamiota commented Jun 18, 2019

Getting same issue. Yesterday it worked good.

@cosivox

This comment was marked as spam.

Copy link

@cosivox cosivox commented Jun 18, 2019

+1 same issue

@nghiant96

This comment has been minimized.

Copy link

@nghiant96 nghiant96 commented Jun 18, 2019

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

@nodece

This comment was marked as spam.

Copy link

@nodece nodece commented Jun 18, 2019

Same issue!!
What happened?

@Deantsui

This comment was marked as off-topic.

Copy link

@Deantsui Deantsui commented Jun 18, 2019

../../../.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/500aadd2483a9fea57affdc292d0d8fc/res/values/values.xml |  
-- | --
error: resource android:attr/ttcIndex not found. |  
@zhllucky

This comment was marked as spam.

Copy link

@zhllucky zhllucky commented Jun 18, 2019

same issue
I need help!

@Chi-AnTai

This comment has been minimized.

Copy link
Contributor

@Chi-AnTai 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

This comment has been minimized.

Copy link

@MR03web 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

This comment has been minimized.

Copy link

@richieroldan richieroldan 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

@nyur321

This comment has been minimized.

Copy link

@nyur321 nyur321 commented Jun 18, 2019

@richieroldan cheers mate

@developerashish01

This comment has been minimized.

Copy link

@developerashish01 developerashish01 commented Jun 18, 2019

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

This comment has been minimized.

Copy link

@cosivox 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

This comment has been minimized.

Copy link

@richieroldan richieroldan commented Jun 18, 2019

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

This comment has been minimized.

Copy link

@matthiasleitner matthiasleitner commented Jun 18, 2019

How to solve this without migrating to AndroidX?

@developerashish01

This comment has been minimized.

Copy link

@developerashish01 developerashish01 commented Jun 18, 2019

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

@tomball123

This comment has been minimized.

Copy link

@tomball123 tomball123 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

This comment has been minimized.

Copy link
Contributor

@Chi-AnTai 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

This comment has been minimized.

Copy link

@js7331 js7331 commented Jun 18, 2019

@matthiasleitner

How to solve this without migrating to AndroidX?

I fixed it via #25292 (comment)

@nodece

This comment has been minimized.

Copy link

@nodece 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

This comment has been minimized.

Copy link

@nodece nodece commented Jun 18, 2019

How to solve this without migrating to AndroidX?

See: #25293 (comment)

@mihaidaviddev

This comment has been minimized.

Copy link

@mihaidaviddev 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

This comment has been minimized.

Copy link
Contributor

@mikehardy mikehardy commented Jun 18, 2019

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 was marked as spam.

Copy link

@hrachqyutukyan hrachqyutukyan commented Jun 18, 2019

dependencies {
implementation "com.google.firebase:firebase-messaging:17.0.0"
implementation("com.google.android.gms:play-services-gcm:16.0.0") {
exclude group: "com.google.android.gms"
}
implementation project(':react-native-device-info'), {
exclude group: "com.google.android.gms"
}
implementation project(':react-native-exception-handler')
implementation project(':react-native-image-picker')
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-android-location-enabler')
implementation project(':react-native-svg')
implementation project(':react-native-push-notification'), {
exclude group: "com.google.android.gms"
exclude group: "com.google.firebase"
}
implementation project(':@react-native-community_async-storage')
implementation project(':react-native-vector-icons')
implementation project(':react-native-maps')
implementation project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: [".jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation fileTree(dir: "libs", include: [".jar"])
implementation project(':react-native-navigation')
implementation project(':react-native-contacts')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-geocoder')
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.facebook.fresco:animated-gif:1.10.0'
implementation project(':react-native-image-picker')
}

my dependencies and still have this issue

@thebusted

This comment was marked as spam.

Copy link

@thebusted thebusted 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.

It working for me after upgrade react-native-device-info to 2.1.2

@adnkh

This comment was marked as outdated.

Copy link

@adnkh adnkh commented Jun 18, 2019

I have been solving this for hours
The most successful solution was to migrate to AndroidX, other solution was headache because of using many dependencies

This is really a problem for someone needs to send a new update urgently and every thing was working fine then suddenly nothing works

@thodubois

This comment has been minimized.

Copy link

@thodubois 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 was marked as resolved.

Copy link

@hrachqyutukyan hrachqyutukyan commented Jun 18, 2019

react-native-device-info version is 2.1.2
It seems related to another dependency.

@adnkh, how to migrate to AndroidX ?

@witalobenicio

This comment was marked as spam.

Copy link

@witalobenicio witalobenicio commented Jun 18, 2019

Nothing seems to work to me.
Tried all above and none worked.

@calintamas

This comment has been minimized.

Copy link

@calintamas calintamas commented Jun 18, 2019

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 was marked as resolved.

Copy link

@divyanshupathak94 divyanshupathak94 commented Jun 18, 2019

@thodubois

buildscript {
ext {
googlePlayServicesVersion = '16.+'
And it works for me.

Not working in my case.

Here is my project dependencies -

dependencies {
    implementation 'com.android.support:design:27.1.0'
    compile project(':react-native-code-push')
    compile project(':appcenter')
    compile project(':appcenter-analytics')
    compile project(':appcenter-crashes')
    compile project(':react-native-smart-splashscreen')
    compile (project(':react-native-device-info')) {
        exclude group: "com.google.android.gms"
    }
    compile project(':react-native-background-timer')
    compile project(':react-native-tts')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-background-job')
    compile project(':react-native-ble-plx')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile project(':react-native-sqlite-storage')
	compile project(':react-native-push-notification')
    compile project(':react-native-fabric')
    compile project(':react-native-preference')
    compile project(':react-native-localization')
    compile project(':react-native-android-location-services-dialog-box')
    compile project(':react-native-bluetooth-status')
    implementation project(':react-native-charts-wrapper')
    compile project(':react-native-android-wifi')
    compile project(':react-native-vector-icons')
    compile project(':react-native-fs')
    compile('com.crashlytics.sdk.android:crashlytics:2.9.7@aar') {
        transitive = true;
    }
    compile project(':react-native-nordic-dfu')
    compile project(':react-native-barcode-scanner-google')
	implementation 'com.google.android.gms:play-services-vision:15.0.2'
	implementation 'com.android.support:multidex:1.0.3'
    compile project(':@merryjs/photo-viewer')
    compile project(':react-native-zip-archive')
    compile project(':react-native-navigation')
    compile project(':react-native-exception-handler')
    compile ('com.android.support:exifinterface:26.+') {
        exclude group: "com.android.support"
    }  
    compile (project(':react-native-camera')) {
        exclude group: "com.google.android.gms"
        exclude group: "com.android.support"
        compile ('com.google.android.gms:play-services-vision:15.0.2') {
            force = true
        }
    }
    compile(project(':react-native-maps')) {
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    compile 'com.google.android.gms:play-services-base:+'
    compile 'com.google.android.gms:play-services-maps:+'
}
@azrirhmn

This comment was marked as spam.

Copy link

@azrirhmn azrirhmn commented Jun 18, 2019

getting same issue

@vitoraguila

This comment was marked as spam.

Copy link

@vitoraguila vitoraguila commented Jun 18, 2019

same issue here

@hrachqyutukyan

This comment has been minimized.

Copy link

@hrachqyutukyan 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 was marked as resolved.

Copy link

@nodece nodece commented Jun 18, 2019

@hrachqyutukyan Migrate to AndroidX is too expensive, react-native-device-info@0.13.0 is work.

@yikkok-yong

This comment was marked as resolved.

Copy link

@yikkok-yong yikkok-yong commented Jun 18, 2019

@divyanshupathak94

compile 'com.google.android.gms:play-services-base:+'
compile 'com.google.android.gms:play-services-maps:+'

Change to the following, any version that is not the latest 17.0.0

compile 'com.google.android.gms:play-services-base:16.1.0'
compile 'com.google.android.gms:play-services-maps:16.1.0'
@witalobenicio

This comment was marked as resolved.

Copy link

@witalobenicio witalobenicio commented Jun 18, 2019

@nodece Are you using compileSdkVersion 28?

@witalobenicio

This comment was marked as resolved.

Copy link

@witalobenicio witalobenicio commented Jun 18, 2019

Anyone there is using react-native-navigation when I try to downgrade to compileSdkVersion 27 it gives me an error:

Could not get unknown property 'mergeResourcesProvider' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.```
@hrachqyutukyan

This comment was marked as resolved.

Copy link

@hrachqyutukyan hrachqyutukyan commented Jun 18, 2019

@hrachqyutukyan Migrate to AndroidX is too expensive, react-native-device-info@0.13.0 is work.

@nodece
but when you have a lot of deps, it will be very difficult

@nodece

This comment was marked as spam.

Copy link

@nodece nodece commented Jun 18, 2019

@nodece Are you using compileSdkVersion 28?

Android ENV

buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"

@witalobenicio

This comment was marked as spam.

Copy link

@witalobenicio witalobenicio commented Jun 18, 2019

@nodece

Anyone there is using react-native-navigation when I try to downgrade to compileSdkVersion 27 it gives me an error:

Could not get unknown property 'mergeResourcesProvider' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.```

@nodece what version of react-native are you using? I'm on 0.59.9 and getting the above error.
:/

@nodece

This comment was marked as spam.

Copy link

@nodece nodece commented Jun 18, 2019

@hrachqyutukyan Migrate to AndroidX is too expensive, react-native-device-info@0.13.0 is work.

@nodece
but when you have a lot of deps, it will be very difficult

Migrating AndroidX is the same.

@nodece

This comment was marked as spam.

Copy link

@nodece nodece commented Jun 18, 2019

@nodece

Anyone there is using react-native-navigation when I try to downgrade to compileSdkVersion 27 it gives me an error:

Could not get unknown property 'mergeResourcesProvider' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.```

@nodece what version of react-native are you using? I'm on 0.59.9 and getting the above error.
:/

RN: 0.57.5

@witalobenicio

This comment was marked as spam.

Copy link

@witalobenicio witalobenicio commented Jun 18, 2019

@nodece could you show us your app/build.gradle please?

@nodece

This comment was marked as spam.

Copy link

@nodece nodece commented Jun 18, 2019

For me it's just impossible to build this sh...t!!

// REMOVED BUILD GRADLE - @kelset

I know it's too big, but thanks in advance if someone can help me.

Google service upgrade seems to be the root cause, I suggest that check build.gradle in node_module.

@bonesyblue

This comment has been minimized.

Copy link

@bonesyblue bonesyblue commented Jun 18, 2019

@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

This comment has been minimized.

Copy link
Collaborator

@kelset 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
You can’t perform that action at this time.