facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.52k stars 24.37k forks source link

Android AAPT: No resource identifier found for attribute 'appComponentFactory' in package 'android' #25296

Closed HunterHR closed 5 years ago

HunterHR commented 5 years ago

🚨 The issue tracker is not for questions. 🚨

As it happens, support requests that are created as issues are likely to be closed. We want to make sure you are able to find the help you seek. Please take a look at the following resources.

Coding Questions

https://stackoverflow.com/questions/tagged/react-native

If you have a coding question related to React Native, it might be better suited for Stack Overflow. It's a great place to browse through frequent questions about using React Native, as well as ask for help with specific questions.

Talk to other React Native developers

https://www.reactiflux.com/

Reactiflux is an active community of React and React Native developers. If you are looking for immediate assistance or have a general question about React Native, the #react-native channel is a good place to start.

If you want to participate in casual discussions about the use of React Native, consider participating in one of the following forums:

If you'd like to discuss topics related to the future of React Native, or would like to propose a new feature or change before sending a pull request, please check out the discussions and proposals repo:

For a full list of community resources, check out React Native's Community page at https://facebook.github.io/react-native/help.

react-native-bot commented 5 years ago

We are automatically closing this issue because it does not appear to follow any of the provided issue templates.

πŸ‘‰ Click here if you want to report a reproducible bug or regression in React Native.

nailikhaled commented 5 years ago

android\app\build\intermediates\manifests\full\release\AndroidManifest.xml:63: AAPT: No resource identifier found for attribute 'appComponentFactory' in package 'android'

FAILURE: Build failed with an exception.

Dhaval240420 commented 5 years ago

hey ant one find any solution, i am getting same issue

BartlomiejKucyniak commented 5 years ago

warning: string 'ucrop_error_input_data_is_absent' has no default translation. warning: string 'ucrop_mutate_exception_hint' has no default translation. /Users/xxx/xxx/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:45: AAPT: No resource identifier found for attribute 'appComponentFactory' in package 'android'

FAILURE: Build failed with an exception.

dhamnesh commented 5 years ago

Facing the same issue. How to resolve??

PixClix commented 5 years ago

Same here. Error is thrown local and in bitrise.

t1amat9409 commented 5 years ago

These bots are quick to close issues for no valid reasonπŸ˜…πŸ˜…... I'm also facing this issue... Can't seem to find a fix online

PixClix commented 5 years ago

Maybe related to this: https://developers.google.com/android/guides/releases#june_17_2019

t1amat9409 commented 5 years ago

Could be so...

viniciusoliveira01 commented 5 years ago

This worked for me.

implementation(project(":react-native-push-notification"), { exclude group: "com.google.android.gms" exclude group: "com.google.firebase" })

After that the notifications stopped working here so I have to add this in my app/android/build.gradle: ext { googlePlayServicesVersion = "16.0.0" firebaseVersion = "17.3.4" }

Now its working perfectly!

See the issue: https://github.com/facebook/react-native/issues/25293

dancherb commented 5 years ago

Also experiencing this issue - have reverted to previous commits and getting the same error, which suggests it's an external issue (like the Google news link given)

prameetc commented 5 years ago

@viniciusoliveira01 Thanks mate! Your solution worked perfectly!

VicEsquivel commented 5 years ago

Any update in the issue?


I solved my issue.

In my case react-native-push-notification was making reference to my project build.gradle to the parameter firebaseVersion and since it was not there, it was using the '+'.

Also my compileSdkVersion needed to be upgraded to 29.

My buid.gradle:

ext {
    compileSdkVersion   = 29
    googlePlayServicesVersion = "15.0.0"
    firebaseVersion = "17.3.4"
}

These 2 coments helped me solve it https://github.com/facebook/react-native/issues/25293#issuecomment-503181071 https://github.com/facebook/react-native/issues/25293#issuecomment-503045776

Pradeep-DCPL commented 5 years ago

Hi guys any update about this issue. i am facing the same

udaisubramaniam commented 5 years ago

Add this to the end of your app/build.gradle dependencies, it forces the gcm library version- so then the third party libraries you're using in your project that are dependent on it, don't break

configurations.all { resolutionStrategy { force 'com.google.android.gms:play-services-gcm:16.1.0' force 'com.google.android.gms:play-services-base:16.1.0' force 'com.google.firebase:firebase-core:16.0.9' force 'com.google.firebase:firebase-messaging:18.0.0' }}

dimlksin2 commented 5 years ago

also came across this problem, is there a solution?

MateuszPrasal commented 5 years ago

@udaisubramaniam solved my problem ! Thanks !

heldercunha commented 5 years ago

Problem solved.

In my case i only add this line in my build.gradle file

ext { buildToolsVersion = '28.0.3' minSdkVersion = 23 compileSdkVersion = 27 targetSdkVersion = 27 supportLibVersion = '27.1.1'

// this line solve my problem
googlePlayServicesVersion = '16.+'

}

t1amat9409 commented 5 years ago

npm i jetifier && npx jetify kinda helped me

graka295 commented 5 years ago

@heldercunha thanks dude, you are hero

cfmitrah commented 5 years ago

@heldercunha Thanks it worked perfectly.

dimlksin2 commented 5 years ago

None of the solutions work for me, are there any other options to fix the problem?

wanxsb commented 5 years ago

@heldercunha Thanks, it worked perfectly

Pradeep-DCPL commented 5 years ago

It worked for me by adding below lines

Android/App/build.gradle

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

To compile 'com.google.android.gms:play-services-base:16.1.0' compile 'com.google.android.gms:play-services-maps:16.0.0'

AND in Android/build.gradle ext { buildToolsVersion = "26.0.3" minSdkVersion = 18 compileSdkVersion = 26 targetSdkVersion = 26 supportLibVersion = "26.1.0" googlePlayServicesVersion = "16.+" firebaseVersion = "17.3.4" }

jsmitrah commented 5 years ago

My team faced this issue in three different projects. Each one need a different fix and all are working fine now. I mentioned all 3 fixes below

Solution 1:

implementation(project(":react-native-push-notification"), { exclude group: "com.google.android.gms" exclude group: "com.google.firebase" })

After that the notifications stopped working here so I have to add this in my app/android/build.gradle: ext { googlePlayServicesVersion = "16.0.0" firebaseVersion = "17.3.4" }


Solution 2:

In another case i only added this line in my build.gradle file

ext { buildToolsVersion = '28.0.3' minSdkVersion = 23 compileSdkVersion = 27 targetSdkVersion = 27 supportLibVersion = '27.1.1'

// this line solve my problem googlePlayServicesVersion = '16.+' }


Solution 3:

Finally in app/build.gradle you can use this

dependencies { compile "com.google.android.gms:play-services-gcm:16.1.0" compile "com.google.firebase:firebase-messaging:17.6.0" compile (project(':react-native-push-notification')) { exclude group: "com.google.android.gms", module: "play-services-gcm" exclude group: "com.google.firebase", module: "firebase-messaging" } ... }

udaisubramaniam commented 5 years ago

I had mentioned the fix for me was this- https://github.com/facebook/react-native/issues/25296#issuecomment-503440779

However incase you use firebase notifications and find they aren't working, add this as well in the dependencies

implementation project(':react-native-firebase') implementation(project(':react-native-push-notification')) { exclude group: 'com.google.android.gms' }

mstratiev commented 5 years ago

It worked for me by adding below lines

Android/App/build.gradle

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

To compile 'com.google.android.gms:play-services-base:16.1.0' compile 'com.google.android.gms:play-services-maps:16.0.0'

AND in Android/build.gradle ext { buildToolsVersion = "26.0.3" minSdkVersion = 18 compileSdkVersion = 26 targetSdkVersion = 26 supportLibVersion = "26.1.0" googlePlayServicesVersion = "16.+" firebaseVersion = "17.3.4" }

god bless you, @Pradeep-DCPL , GOD BLESS YOU was about to lose my cool if that damn debugging and configs and stuff would continue for another 4 hours needed only the firebaseVersion, but still, very very hard to figure out jusst like that, and I DID really try everything imaginable. Next time I am doing my own server for the packages and caching everything, because that is like the 5th time this year that Google does whatever breaking change and using the latest versions would get me a build that is compiling one day and does not the other.

leuducquy commented 5 years ago

god bless you, @Pradeep-DCPL You save my life . For me i did change from compile 'com.google.android.gms:play-services-base:+' to implementation 'com.google.android.gms:play-services-base:16.1.0' and it work

Subway19 commented 5 years ago

@Pradeep-DCPL Thanks so much. It works.

patrickgalbraith commented 5 years ago

For me the issue was with react-native-device-info but it will happen with anything that uses v17+ of play-services-gcm.

The fix was to add this to our android/build.gradle to force the version.

def versionOverrides = [
    "com.google.android.gms:play-services-gcm": "16.+"
]

subprojects {
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def overrideVersion = versionOverrides[details.requested.group + ":" + details.requested.name]

            if (overrideVersion != null && details.requested.version != overrideVersion) {
                logger.info "Overriding dependency ${details.requested.group}:${details.requested.name} version ${details.requested.version} --> $overrideVersion"
                details.useVersion overrideVersion
            }
        }
    }
}

You will get "Overriding dependency..." messages which will tell you which packages are being replaced.

Credit to Howard Lewis Ship for the gradle override code.

ppv94 commented 5 years ago

i am getting same error AAPT: No resource identifier found for attribute 'appCompon entFactory' in package 'android'

i changed googlePlayServicesVersion = '+' to googlePlayServicesVersion = '16.+'

what should i do this is my build.gradle ext { googlePlayServicesVersion = '16.+' buildToolsVersion = "27.0.3" minSdkVersion = 16 compileSdkVersion = 27 targetSdkVersion = 26 supportLibVersion = "27.1.0" }

and my dependencies :

dependencies { compile project(':react-native-image-crop-picker') //compile project(':react-native-facebook-account-kit') compile project(':react-native-youtube') compile project(':react-native-vector-icons') compile project(':react-native-compress-image') compile project(':lottie-react-native') compile project(':react-native-gesture-handler') compile project(':react-native-image-picker') compile project(':react-native-fbads') compile project(':react-native-admob') compile project(':react-native-share') compile project(':react-native-android-permissions') compile project(':react-native-view-shot') compile project(':react-native-image-resizer') compile project(':react-native-fs') compile 'com.facebook.fresco:fresco:1.8.1' compile 'com.facebook.fresco:animated-gif:1.8.1' // For WebP support, including animated WebP compile 'com.facebook.fresco:animated-webp:1.3.0' compile 'com.facebook.fresco:webpsupport:1.3.0' // For WebP support, without animations compile 'com.facebook.fresco:webpsupport:1.3.0' compile project(':react-native-fetch-blob') compile project(':react-native-svg') compile project(':react-native-fbsdk') compile project(':react-native-linear-gradient') compile fileTree(dir: "libs", include: ["*.jar"]) implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" implementation ("com.android.support:support-v4:${rootProject.ext.supportLibVersion}") implementation ("com.android.support:design:${rootProject.ext.supportLibVersion}") compile 'com.google.android.gms:play-services-ads:16.0.0' compile "com.facebook.react:react-native:+" // From node_modules compile 'com.google.android.gms:play-services-auth:+' // should be at least 9.0.0 implementation (project(':react-native-facebook-account-kit')) { exclude group: "com.android.support" } }

vvusts commented 5 years ago

For me issue was solved by upgrading react-native-device-info to latest version (2.1.1) and changed compileSDK from 27 to 28 (also need to install SDK28 from SDK Manager).

baotoan1905 commented 5 years ago

For me issue was solved by upgrading react-native-device-info to latest version (2.1.1) and changed compileSDK from 27 to 28 (also need to install SDK28 from SDK Manager).

OMG, OMG. You are my life saviour. I changed the compileSDK from 27 to 28 then it's working like a charm. Thanks man. BTW, can you share how you know that we need to increase the compileSDK ?

vvusts commented 5 years ago

Read this.

ppv94 commented 5 years ago

upgrading react-native-device-info to latest version (2.1.1) and changed compileSDK from 27 to 28 i am getting below error

Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.

com.android.build.api.transform.TransformException: Error while generating the main dex list.

what should i do

Keerato commented 5 years ago

After upgrading react-native-device-info to the latest version (2.1.1) and changed compile SDK from 27 to 28, I am getting below error

Execution failed for task ':app:transformClassesWithJarMergingForRelease'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/app/INotificationSideChannel$Stub$Proxy.class

What should I do next?

nailikhaled commented 5 years ago

Add this section to dependencies.gradle file

configurations.all { resolutionStrategy { force 'com.google.android.gms:play-services-gcm:16.1.0' force 'com.google.android.gms:play-services-base:16.1.0' force 'com.google.firebase:firebase-core:16.0.9' force 'com.google.firebase:firebase-messaging:18.0.0' }}

ppv94 commented 5 years ago

Add this section to dependencies.gradle file

configurations.all { resolutionStrategy { force 'com.google.android.gms:play-services-gcm:16.1.0' force 'com.google.android.gms:play-services-base:16.1.0' force 'com.google.firebase:firebase-core:16.0.9' force 'com.google.firebase:firebase-messaging:18.0.0' }}

but am not using any firebase in my project here is my build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

subprojects { afterEvaluate {project -> if (project.hasProperty("android")) { android { compileSdkVersion 28 buildToolsVersion "27.0.2" } } } }

subprojects { if (project.name.contains('react-native-vector-icons')) { buildscript { repositories { jcenter() maven { url "https://dl.bintray.com/android/android-tools/" } } } } }

buildscript {

ext { googlePlayServicesVersion="15.0.1" buildToolsVersion = "27.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 26 supportLibVersion = "27.1.0" }

repositories {
    jcenter()
    google()
}
dependencies {
     classpath 'com.android.tools.build:gradle:3.1.4'
     classpath 'com.google.gms:google-services:3.2.1'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

subprojects { if (project.name.contains('react-native-vector-icons')) { buildscript { repositories { maven { url "https://dl.bintray.com/android/android-tools/" } jcenter() } } } }

subprojects { if (project.name.contains('react-native-image-picker')) { buildscript { repositories { maven { url "https://dl.bintray.com/android/android-tools/" } jcenter() } } } }

allprojects { repositories { mavenLocal() jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } configurations.all { resolutionStrategy { force 'com.facebook.android:facebook-android-sdk:4.28.0' } } maven { url "https://jitpack.io" } maven { url "https://maven.google.com" } } }

SaiKiran322 commented 5 years ago

It worked for me by adding below lines

Android/App/build.gradle

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

To compile 'com.google.android.gms:play-services-base:16.1.0' compile 'com.google.android.gms:play-services-maps:16.0.0'

AND in Android/build.gradle ext { buildToolsVersion = "26.0.3" minSdkVersion = 18 compileSdkVersion = 26 targetSdkVersion = 26 supportLibVersion = "26.1.0" googlePlayServicesVersion = "16.+" firebaseVersion = "17.3.4" }

@Pradeep-DCPL LifeSaviour <3

Leinadio commented 5 years ago

After a little tour on the internet. I did this.

Step 1: Add in the android/build.gradle. googlePlayServicesVersion = "16.0.0" firebaseVersion = "17.3.4"

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 19
        compileSdkVersion = 28
        targetSdkVersion = 27
        supportLibVersion = "28.0.0"
        googlePlayServicesVersion = "16.0.0"
        firebaseVersion = "17.3.4"
    }
   ...

Step 2: cd android && ./gradlew assemble

Step 3: Open android studio and open an android emulator. Mine is on Pixel XL API 27

Step 4: react-native run-android

dengue8830 commented 5 years ago

thanks to @udaisubramaniam. Fixed with this

at the end of your android/app/build.gradle (before apply plugin line if you have that line)

configurations.all {
  resolutionStrategy {
    force 'com.google.android.gms:play-services-gcm:16.1.0'
  }
}

that fixes two issues:

Explanation: gms has upgraded to androidx so all the libs that use it as dependency had defined it as :gms+ so when google released a breaking change they all updated to it and broke everything

Solutions: 1) upgrade your project and dependencies in order to use androidx. Not all you dependencies are using it so i don't know if this is a good idea. 2) force the project to use a previous version of the gms lib. This could be a problem? may be, will see πŸ˜† it's building fine for now

I will wait until all the libs upgrade to androidx and then migrate the project to rn60

UPDATE: Seeing the useful resources below, you have to upgrade your android project to sdk 28 (i have had already done that because it's a good practice). If you use android studio it will propose you to automagically upgrade to the config below

this is my ext config in android/build.gradle

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
}

also i'm using classpath 'com.android.tools.build:gradle:3.3.2' gradle version 4.10.1

Useful resources

https://github.com/facebook/react-native/issues/25307 https://github.com/facebook/react-native/issues/25296#issuecomment-503440779 https://github.com/facebook/react-native/issues/25301 https://stackoverflow.com/questions/56648263/android-dependency-com-google-android-gmsplay-services-stats-has-different-ve

Tuapplicacion commented 5 years ago

I'm having the same problem, I've tried everything and I haven't been luck.

android/build.gradle

` ext {

buildToolsVersion = "26.0.3"
minSdkVersion = 16
compileSdkVersion = 26
targetSdkVersion = 26
supportLibVersion = "26.1.0"
googlePlayServicesVersion="12.0.1"

}

`

app/build.gradle

` dependencies {

compile project(':react-native-view-overflow')
compile project(':react-native-video')
compile project(':react-native-vector-icons')
compile project(':react-native-splash-screen')
compile project(':react-native-sentry')
compile project(':react-native-push-notification')
compile project(':react-native-onesignal')
compile project(':react-native-localization')
compile project(':react-native-keep-awake')
compile project(':react-native-image-crop-picker')
compile project(':react-native-google-places')
compile project(':react-native-gesture-handler')
compile project(':react-native-geolocation-service')
compile project(':react-native-firebase')
compile project(':react-native-fcm')
compile project(':react-native-fbsdk')
compile project(':react-native-device-info')
compile project(':react-native-code-push')
compile project(':react-native-camera')
compile project(':react-native-android-location-services-dialog-box')
compile project(':react-native-admob')
implementation project(':react-native-code-push')
implementation project(':react-native-view-overflow')
implementation project(':react-native-admob')
implementation project(':react-native-sentry')
implementation project(':react-native-keep-awake')
implementation project(':react-native-firebase')
implementation 'com.facebook.android:facebook-android-sdk:4.37.0'
implementation 'com.facebook.android:facebook-marketing:4.37.0' 
implementation project(':react-native-fbsdk')
implementation project(':react-native-vector-icons')
implementation project(':react-native-geolocation-service')
implementation project(':react-native-push-notification')
implementation project(':react-native-google-places')
implementation "com.google.android.gms:play-services-base:16.0.1"
implementation "com.google.firebase:firebase-core:16.0.6"
// implementation 'com.google.firebase:firebase-core'
// implementation 'com.google.firebase:firebase-messaging'
implementation 'com.android.support:multidex:1.0.3'
implementation project(':react-native-onesignal')
implementation project(':react-native-camera')
implementation project(':react-native-splash-screen')
implementation project(':react-native-video')
implementation (project(':react-native-camera')) {
    exclude group: "com.google.android.gms"
    implementation 'com.android.support:exifinterface:+'
    implementation ('com.google.android.gms:play-services-vision:12.0.1') {
        force = true
    }
}
implementation project(':react-native-android-location-services-dialog-box')
implementation project(':react-native-device-info'), {
    exclude group: "com.google.android.gms"
}
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-localization')
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 'com.google.android.gms:play-services-ads:17.1.1'

}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' apply plugin: 'com.google.gms.google-services'

`

I already have test all fixes in the previous posts and nothing seems to work for me.

dengue8830 commented 5 years ago

you have to upgrade to android 28, i will update my last answer, check it my ext android build config

cesarPHP commented 5 years ago

Hi, i'm using cordova apache for mobile apps, but i got the same error when i compile. I'm using too firebase and google maps plugin's. I did all the posible solutions that you show here with the build.gradle And, i have not luck, please help!!!

t1amat9409 commented 5 years ago

@cesarPHP did you migrate to androidx?

cesarPHP commented 5 years ago

mmm, no, how i do that?

Keerato commented 5 years ago

I've tried all of the solutions here, but it still doesn't work. I want to identify the reason for this issue. So, please corrects me if I'm wrong.

This issue is due to some libs we are using already upgrade to AndroidX. But some libs are still not upgraded. So, its dependencies (such as gms+) have a conflict with each other.

The ways to solve this are:

  1. wait until all libs upgrade to AndroidX
  2. downgrade all libs not to use AndroidX
wongjow0 commented 5 years ago

After upgrading react-native-device-info to the latest version (2.1.1) and changed compile SDK from 27 to 28, I am getting below error

Execution failed for task ':app:transformClassesWithJarMergingForRelease'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/app/INotificationSideChannel$Stub$Proxy.class

What should I do next?

same problem @t1amat9409

t1amat9409 commented 5 years ago

thanks to @udaisubramaniam. Fixed with this

at the end of your android/app/build.gradle (before apply plugin line if you have that line)

configurations.all {
  resolutionStrategy {
    force 'com.google.android.gms:play-services-gcm:16.1.0'
  }
}

that fixes two issues:

  • firebase appComponentFactory androidx problem
  • react-native-device-info Android dependency 'com.google.android.gms:play-services-stats' has >different version for the compile (16.0.1) and runtime (17.0.0)

Explanation: gms has upgraded to androidx so all the libs that use it as dependency had defined it as :gms+ so when google released a breaking change they all updated to it and broke everything

Solutions:

  1. upgrade your project and dependencies in order to use androidx. Not all you dependencies are using it so i don't know if this is a good idea.
  2. force the project to use a previous version of the gms lib. This could be a problem? may be, will see laughing it's building fine for now

I will wait until all the libs upgrade to androidx and then migrate the project to rn60

UPDATE: Seeing the useful resources below, you have to upgrade your android project to sdk 28 (i have had already done that because it's a good practice). If you use android studio it will propose you to automagically upgrade to the config below

this is my ext config in android/build.gradle

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
}

also i'm using classpath 'com.android.tools.build:gradle:3.3.2' gradle version 4.10.1

Useful resources

25307

#25296 (comment)

25301

https://stackoverflow.com/questions/56648263/android-dependency-com-google-android-gmsplay-services-stats-has-different-ve

@bundamasakan did you try the above? if not... then you need to install jetifier

npm i jetifier && npx jetify

This will help migrate your project to android x and resolve all conflicts... you might have to jetify your project every time you npm install

wongjow0 commented 5 years ago

@bundamasakan did you try the above? if not... then you need to install jetifier

npm i jetifier && npx jetify

This will help migrate your project to android x and resolve all conflicts... you might have to jetify your project every time you npm install

still with the same problem. is there another way @t1amat9409