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 AAPT: No resource identifier found for attribute 'appComponentFactory' in package 'android' #25296

Closed
HunterHR opened this issue Jun 18, 2019 · 63 comments
Labels
Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.

Comments

@HunterHR
Copy link

🚨 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.

@HunterHR HunterHR added the Type: Question Issues that are actually questions and not bug reports. label Jun 18, 2019
@react-native-bot react-native-bot added the Platform: Android Android applications. label Jun 18, 2019
@react-native-bot
Copy link
Collaborator

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.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Resolution: No Template labels Jun 18, 2019
@nailikhaled
Copy link

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.

  • What went wrong:
    Execution failed for task ':app:processReleaseResources'.

Failed to process resources, see aapt output above for details.

@Dhaval240420
Copy link

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

@BartlomiejKucyniak
Copy link

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.

  • What went wrong:
    Execution failed for task ':app:processDebugResources'.

Failed to process resources, see aapt output above for details.

@dhamnesh
Copy link

Facing the same issue. How to resolve??

@PixClix
Copy link

PixClix commented Jun 18, 2019

Same here. Error is thrown local and in bitrise.

@t1amat9409
Copy link

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
Copy link

PixClix commented Jun 18, 2019

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

@t1amat9409
Copy link

Could be so...

@viniciusoliveira01
Copy link

viniciusoliveira01 commented Jun 18, 2019

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: #25293

@dancherb
Copy link

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
Copy link

@viniciusoliveira01 Thanks mate! Your solution worked perfectly!

@VicEsquivel
Copy link

VicEsquivel commented Jun 19, 2019

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
#25293 (comment)
#25293 (comment)

@Pradeep-DCPL
Copy link

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

@udaisubramaniam
Copy link

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
Copy link

also came across this problem, is there a solution?

@MateuszPrasal
Copy link

@udaisubramaniam solved my problem ! Thanks !

@heldercunha
Copy link

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
Copy link

npm i jetifier && npx jetify kinda helped me

@graka295
Copy link

@heldercunha thanks dude, you are hero

@cfmitrah
Copy link

@heldercunha Thanks it worked perfectly.

@dimlksin2
Copy link

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

@wanxsb
Copy link

wanxsb commented Jun 19, 2019

@heldercunha Thanks, it worked perfectly

@Pradeep-DCPL
Copy link

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"
}

@Keerato
Copy link

Keerato commented Jun 20, 2019

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
Copy link

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
Copy link

ppv94 commented Jun 21, 2019

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
Copy link

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
Copy link

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
Copy link

dengue8830 commented Jun 21, 2019

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 😆 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

@Tuapplicacion
Copy link

Tuapplicacion commented Jun 22, 2019

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
Copy link

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

@cesarPHP
Copy link

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
Copy link

@cesarPHP did you migrate to androidx?

@cesarPHP
Copy link

mmm, no, how i do that?

@Keerato
Copy link

Keerato commented Jun 25, 2019

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
Copy link

wongjow0 commented Jun 25, 2019

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
Copy link

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
Copy link

@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

@t1amat9409
Copy link

If you did jetify. Remove all references to android.* in your app/build.gradle ...
Make sure you have a copy just in case, but it worked for me.

The duplicates are cause by android.* libraries

@andrewhartwig
Copy link

@dengue8830 I owe you a beer sir, your solution of adding

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

resolved my situation without having to tinker with anything else.

I wish I understood what any of this does better. I get really stressed out when these random google issues occur!

@dengue8830
Copy link

dengue8830 commented Jun 26, 2019

@andrewhartwig that forces the project to use that specific version of that lib for all the implicit dependencies used within the libs you have installed. If you check the versions of that lib (gcm) you will see the latest versions are 16.1 and 17 and if you check inside of each one, version 17 has androidx dependencies.

So the problem the other guys have are in the same direction, they are using some lib that has androidx as dependency (just like gcm example). You guys should execute the command that draws a dependency tree (you can find that in the resources mentioned above) and there you will see wich lib is using androidx so you can include it in the force line config with a version where that lib doesn't use androidx (you should check the lib version history in order to get that).

@andrewhartwig
Copy link

Thank you @dengue8830 great explanation!

@Alferdize
Copy link

please help I am stuck in push notification issue.I have tried all the above solution. my react-native info is
React Native Environment Info: System: OS: macOS High Sierra 10.13.6 CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz Memory: 48.23 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 11.0.0 - /usr/local/bin/node npm: 6.7.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 Android SDK: API Levels: 23, 24, 25, 26, 27, 28, 29 Build Tools: 26.0.2, 27.0.3, 28.0.0, 28.0.1, 28.0.2, 28.0.3, 29.0.0 System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-27 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom IDEs: Android Studio: 3.4 AI-183.6156.11.34.5522156 Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728 react-native: ^0.57.8 => 0.57.8 npmGlobalPackages: react-native-asset: 1.1.3 react-native-cli: 2.0.1 react-native-contacts-wrapper: 0.2.4 react-native-contacts: 4.0.2 react-native-push-notification: 3.1.3
my android build gradle is:
`// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = "28.0.0"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 26
supportLibVersion = "27.1.1"
googlePlayServicesVersion = "16.0.0"
firebaseVersion = "17.0.0"
}
repositories {
google()
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.2.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

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

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

task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
`

and my app build gradle is:
`apply plugin: "com.android.application"

import com.android.build.OutputFile

/**

  • The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
  • and bundleReleaseJsAndAssets).
  • These basically call react-native bundle with the correct arguments during the Android build
  • cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
  • bundle directly from the development server. Below you can see all the possible configurations
  • and their defaults. If you decide to add a configuration block, make sure to add it before the
  • apply from: "../../node_modules/react-native/react.gradle" line.
  • project.ext.react = [
  • // the name of the generated asset file containing your JS bundle
  • bundleAssetName: "index.android.bundle",
  • // the entry file for bundle generation
  • entryFile: "index.android.js",
  • // whether to bundle JS and assets in debug mode
  • bundleInDebug: false,
  • // whether to bundle JS and assets in release mode
  • bundleInRelease: true,
  • // whether to bundle JS and assets in another build variant (if configured).
  • // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
  • // The configuration property can be in the following formats
  • // 'bundleIn${productFlavor}${buildType}'
  • // 'bundleIn${buildType}'
  • // bundleInFreeDebug: true,
  • // bundleInPaidRelease: true,
  • // bundleInBeta: true,
  • // whether to disable dev mode in custom build variants (by default only disabled in release)
  • // for example: to disable dev mode in the staging build type (if configured)
  • devDisabledInStaging: true,
  • // The configuration property can be in the following formats
  • // 'devDisabledIn${productFlavor}${buildType}'
  • // 'devDisabledIn${buildType}'
  • // the root of your project, i.e. where "package.json" lives
  • root: "../../",
  • // where to put the JS bundle asset in debug mode
  • jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
  • // where to put the JS bundle asset in release mode
  • jsBundleDirRelease: "$buildDir/intermediates/assets/release",
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in debug mode
  • resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in release mode
  • resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
  • // by default the gradle tasks are skipped if none of the JS files or assets change; this means
  • // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
  • // date; if you have any other folders that you want to ignore for performance reasons (gradle
  • // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
  • // for example, you might want to remove it from here.
  • inputExcludes: ["android/", "ios/"],
  • // override which node gets called and with what additional arguments
  • nodeExecutableAndArgs: ["node"],
  • // supply additional arguments to the packager
  • extraPackagerArgs: []
  • ]
    */

project.ext.react = [
entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**

  • Set this to true to create two separate APKs instead of one:
    • An APK that only works on ARM devices
    • An APK that only works on x86 devices
  • The advantage is the size of the APK is reduced by about 4MB.
  • Upload all the APKs to the Play Store and people will download
  • the correct one based on the CPU architecture of their device.
    */
    def enableSeparateBuildPerCPUArchitecture = false

/**

  • Run Proguard to shrink the Java bytecode in release builds.
    */
    def enableProguardInReleaseBuilds = false

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
    applicationId "com.gosociety"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}
signingConfigs {
    release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}


configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.0'

    }
}

splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
    }
}

}

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

implementation project(':react-native-image-picker')


implementation project(':react-native-contacts')
implementation project(':react-native-svg')
implementation project(':react-native-contacts-chooser')
implementation project(':react-native-i18n')
implementation project(':react-native-locale-detector')
implementation project(':rn-fetch-blob')
implementation project(':react-native-share')
implementation project(':react-native-image-to-pdf')


implementation project(':react-native-charts-wrapper')

implementation project(':react-native-vector-icons')
implementation project(':react-native-fs')

implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+"  // From node_modules

}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

// apply plugin: 'com.google.gms.google-services'`

the app crashes whenever the push-notification is called in my login.js file:
`
import React, {Component} from 'react';
import {
Platform,
StyleSheet,
ImageBackground,
TouchableOpacity,
AsyncStorage,
Dimensions,
NetInfo,
ActivityIndicator,
View,
BackHandler,
Alert
} from 'react-native';
import {
Container,
Text,
Body,
Button,
Input,
Item,
CheckBox,
Right,
Left,
Title,
Thumbnail
} from 'native-base';
import Icon from 'react-native-vector-icons/FontAwesome';
import PushNotification from 'react-native-push-notification'
// var PushNotification = require('react-native-push-notification');
import Global from '../global/Global';
import Constant from '../global/Constants';
import VerifyUser from '../mutation/login/verifyUser';
import updateUserToken from '../mutation/updateUserToken';
import { withApollo, compose,graphql,Query } from 'react-apollo'
import GetWings from '../query/tracker/GetWings.js'
import { strings } from '../locales/I18n';
import I18n from 'react-native-i18n';
import AwesomeAlert from 'react-native-awesome-alerts';

import gql from 'graphql-tag';
import Constants from '../global/Constants';

// true means invalid, so our conditions got reversed
class Login extends Component {
constructor(props){
super(props);
this.state={
// username: '8459832342',
// password: 'khan',
// username: '8483077289',
// password: 'anubhavsharma',
username: '',
password: '',
// username: '',
// password: '',
icon:1,
True:'',
connection_Status : "",
Error1:'0',
Error:'',
isUserLoggedIn:false,
placeholder_userName:'',
placeholder_password:'',
app_lang:'',
showAlert:true,
alertText:'',
}

}

componentWillMount(){
this.exitApp();
this.getAppLanguage();

if (Platform.OS == "android") {
  BackHandler.addEventListener('hardwareBackPress', this.handleBackButton);                           

}

}

componentWillUnmount() {
if (Platform.OS == "android") {
BackHandler.addEventListener('hardwareBackPress', this.handleBackButton);
}

}

/*
Alert to exit application
*/
exitApp = () => {

BackHandler.addEventListener('hardwareBackPress', function() {
Alert.alert(
strings('alert.exit_app_title'),
strings('alert.exit_app_msg'), [{
text: 'Cancel',
onPress: () => console.log('Cancel Pressed'),
style: 'cancel'
}, {
text: 'OK',
onPress: () => BackHandler.exitApp()
}, ], {
cancelable: false
}
)
return true;
})

}

//Exit app wih back button press
handleBackButton = () => {

if (this.props.isFocused) {
Alert.alert(
'Exit App',
'Exiting the application?',
[
{
text: 'Cancel',
onPress: () => console.log('Cancel Pressed'),
style: 'cancel'
},
{
text: 'OK',
onPress: () => BackHandler.exitApp()
}
],
{
cancelable: false
}
);
return true;
}
};

// registerToken = (mob,slugSocName)=>{
// console.log("crash")
// let self = this;

// PushNotification.configure({
// onError: function(e) {
// console.log('onErro ::',e)
// },
// onRegister: function ({token, os}) {
// console.log('TOKEN:', token);

// AsyncStorage.setItem('token', JSON.stringify(token));
// self.updateTokenInDB(mob ,token, slugSocName)
// },
// onNotification: function (notification) {
// console.log('NOTIFICATION:', notification);
// },
// senderID: "1087021464546",
// permissions: {
// alert: true,
// badge: true,
// sound: true
// },
// popInitialNotification: true,
// requestPermissions: true,
// });
// console.log("op")

// }

registerToken = (mob,slugSocName)=>{

console.log("In reg ::",mob, slugSocName)
let self = this;

try {

PushNotification.configure({

onError: function(e) {
  console.log('onError ::',e)
},
onRegister: function ({token}) {
  console.log('TOKEN:', token);
  
  AsyncStorage.setItem('token', JSON.stringify(token));
  self.updateTokenInDB(mob ,token, slugSocName)
},

onNotification: function (notification) {
  console.log('NOTIFICATION:', notification);
},
senderID: "1087021464546",
permissions: {
  alert: true,
  badge: true,
  sound: true
},
popInitialNotification: true,
requestPermissions: true,

});

} catch (error) {
console.log('In reg catch :',error)
}
}

updateTokenInDB = (mob, token,slugSocName)=>{

// const user = JSON.parse(this.state.admin)

console.log('in updateTokenDB ::',mob,token)

this.props.UpdateUserToken({
variables: {
slugSocName: slugSocName,
mob: mob,
token
}
})
.then(({ data }) => {

  console.log('In Update token success :',data)

})
.catch((err) => {
  console.log(`Update Token : in err: ${JSON.stringify(err)}`);
});

}

//get app language
getAppLanguage = () => {
AsyncStorage.getItem(Constants.APP_LANGUAGE).then(value =>{
I18n.locale = value;
this.setState({
app_lang:value
})
})
}

componentDidMount() {
NetInfo.isConnected.addEventListener(
'connectionChange',
this._handleConnectivityChange

);
NetInfo.isConnected.fetch().done((isConnected) => {

if(isConnected == true)
{
  this.setState({connection_Status : "Online"})
}
else
{
  this.setState({connection_Status : "Offline"})
}

});
}

connection() {
// prevent memory leaks!
NotificationsIOS.removeEventListener('remoteNotificationsRegistered', this.onPushRegistered.bind(this));
NotificationsIOS.removeEventListener('remoteNotificationsRegistrationFailed', this.onPushRegistrationFailed.bind(this));
NetInfo.isConnected.removeEventListener(
'connectionChange',
this._handleConnectivityChange);
}
_handleConnectivityChange = (isConnected) => {

if(isConnected == true)
{
this.setState({connection_Status : "Online"})
}
else
{
this.setState({connection_Status : "Offline"})
}
};
press =()=>{
const { icon} = this.state
if(icon==0){
this.setState({icon:1});
}
else{
this.setState({icon:0});

}
}

signUp = () => {
const { username, password} = this.state
this.setState({Error1:'0'});
const reg = /^[0]?[789]\d{9}$/;
if(reg.test(username) === false){
this.setState({Error:'please fill the valid phone no.'});
this.setState({Error1:'1'});
}
else if(password==""){
this.setState({Error:'please fill the passsword'});
this.setState({Error1:'2'});
}

else {
  this.props.navigation.navigate("PersonalInfoForm" )

}
}
_storeData = async (data) => {
try {
await AsyncStorage.setItem('ownerDetails', JSON.stringify(data));
console.log("IN store data funtion")
} catch (error) {
console.log("Data is not Available")
}
}
_storeWings = async (data) => {
try {
await AsyncStorage.setItem('Wings', JSON.stringify(data));
console.log("Wings Stored")
} catch (error) {
console.log("Data is not Available")
}
}
getWings = (slugSocName) => {
this.props.client
.query({
query: GetWings,
variables: {
mId: ${slugSocName}::wing
},
fetchPolicy: "network-only"
})
.then(({ data }) => {
this.setState({ loading: false });

    console.log('Wings ::',data.getSocietyMetaById)

    if (data.getSocietyMetaById != null) {
      this._storeWings(data.getSocietyMetaById)

    } 
  })
  .catch(err => {
    this.setState({ loading: false });


  });

}

// Verify User
verifyCredintials = () => {
console.log("in login pres >>>")
const { username, password, connection_Status} = this.state;
if((username == '' || username.length == 0) && (password == '' || password.length == 0)){
alert(strings('errors.please_enter_username_password'))
}else if(username == '' || username.length == 0){
alert(strings('errors.please_enter_mobile'))
}else if(password == '' || password.length == 0){
alert(strings('errors.please_enter_password'))
}else if(username.length > 0 && password.length > 0){
this.checkInternetConnection();
}else{
alert("Please fill all details");
}
}

/*
Check Internet connection
*/
checkInternetConnection = () => {
NetInfo.isConnected.fetch ().then (result => {
if (result) {
this.login();
} else {
alert ('No internet connection');
this.setState ({
isInternetAvailable: false,
});
}
});
};

//Verify user
login = () => {
const { username, password, connection_Status} = this.state
this.connection
console.log('uname :',username,password)
if(connection_Status == "Online")
{
this.setState({True: 1})
this.props.VerifyUser({
variables: {
"mob": username,
"pass": password
}
})
.then(({ data }) => {
// console.log("login data = " + JSON.stringify(data))
console.log("login Succ = ")

  if(data.verifyUser == null){
    alert("Please check username or password");
    setTimeout(()=>{this.setState({True: ''})}, 2000);
  }else{
  AsyncStorage.setItem(Constant.IS_USER_LOGGED_IN , true.toString());
    // this.onReg()
   // this.registerToken(data.verifyUser.mob,data.verifyUser.slugSocName)
   this.registerToken(data.verifyUser.mob,data.verifyUser.slugSocName)
    console.log("crash2")
   this._storeData(data.verifyUser)
   this.getWings(data.verifyUser.slugSocName);
   setTimeout(()=>{this.setState({True: ''})}, 2000);
   if(data.verifyUser.role=="flatOwner"){        
    setTimeout(()=>{this.props.navigation.navigate('Navigate')}, 1500);
   }
   else{
    setTimeout(()=>{this.props.navigation.navigate('PersonalInfoForm')}, 1500);
   }
  
  }
    
  })
  .catch((err) => {
    setTimeout(()=>{this.setState({True: ''})}, 100);
    alert(`${JSON.stringify(err)}`);
    //alert("Please check username or password")
  });
}
else{
  alert("You Are Offline");
}

}

showAlert = () => {
this.setState({
showAlert: true
});
};

hideAlert = () => {
this.setState({
showAlert: false
});
};

render () {
const {showAlert , alertText} = this.state;

let pic = {
  uri: 'http://www.tokkoro.com/picsup/2407175-abstract-blue-light-pink-and-orange-color-gradient-background.jpg',
};
return (
  
  <Container style = {Global.container}>
 
      <Body style={styles.LoBody}>
   
       
        <Thumbnail source={require('../image/logo.png')} style={styles.Iconstyle} large/>
          <Body style = {styles.loginContainer}>
  
        <Item  style={Global.Itemtstyle} rounded >
        <Input style = {[Global.InputStyle,Global.appFont]}
         placeholder = {strings('login.enter_mobile_no')}
        keyboardtype='numeric'
        value = {this.state.username}
        onChangeText={username=>this.setState({username})} 
        />
        <Icon active name='user-circle' color='black'  size={25}/>


        </Item>

        {this.state.Error1 === '1'? <Text style={Global.ErrorStyle}>{this.state.Error}</Text>: <Text></Text> }
        <Item  style={Global.Itemtstyle} rounded>
        <Input style = {[Global.InputStyle,Global.appFont]}
        placeholder = {strings('login.enter_password')}
        value = {this.state.password}
        secureTextEntry = {this.state.icon === 0 ? false : true }
        onChangeText={password=>this.setState({password})} 
        />
        <Icon active size={25} color='black' name={this.state.icon === 0 ? 'eye' : 'eye-slash' } 
         onPress={this.press}/>
      
  
        </Item>
        {this.state.Error1 === '2'? <Text style={Global.ErrorStyle}>
        {this.state.Error}</Text>: <Text></Text> }
      { this.state.True === '' ? 
      
      <Button  full onPress = {this.verifyCredintials.bind(this)}   style={[Global.loginbutton,Global.appFont,{borderRadius:25}]}>
      <Text style={[Global.AppHeaderTextStyle , Global.appFont]}>
      {strings('login.login')}
      </Text>
     
        </Button>
        
     : <View style={[styles.container1, styles.horizontal]}>
    <ActivityIndicator size="large" color="#5c007a" />
  </View>}
     

     <Button  transparent style = {[Global.ResetLink,Global.appFont]} 
     onPress = {() => this.props.navigation.navigate("ChangepasswordScreen")}>
     <Text style={[Global.Bluecolor,Global.appFont]}>
     {strings('login.forgot_password')}
      </Text>
     </Button>

        </Body>
        </Body>


  </Container>
);

}
}
const styles = StyleSheet.create ({
container: {
width: '100%',
height: '100%',
flex: 1,
},
RemFont:{
fontSize: 20
},
RemMar:{
margin:15
},
Iconstyle:{
width:200,
height:100,
marginTop:30,
marginBottom: 20,
},
HeaderLo:{
width:420,
height:60,
alignItems: 'center',
backgroundColor: '#5c007a'
},
LoBody:{
alignItems: 'center',
paddingHorizontal:20 ,
marginTop:30
},
LoItem:{
alignItems: 'center',
borderBottomWidth:0
},
loginContainer:{
marginTop:20
},
});

// export default Login;

const LoginPage = compose(
withApollo,
graphql(VerifyUser,{name: "VerifyUser"}),
graphql(updateUserToken,{name: "UpdateUserToken"}),

)(Login)

export default LoginPage;
`
please help Thank you.

@baotoan1905
Copy link

baotoan1905 commented Jun 28, 2019

@Alferdize
I got the same issue with react-native-push-notification. I fixed it by upgrading to the latest react-native-push-notification 3.1.3.
Then From app/build.gradle I added the following

implementation(project(":react-native-push-notification"), { exclude group: "com.google.android.gms" exclude group: "com.google.firebase" }) implementation "com.google.android.gms:play-services-gcm:${rootProject.ext.googlePlayServicesVersion}" implementation "com.google.firebase:firebase-messaging:${rootProject.ext.firebaseVersion}"

in build.gradle I added

ext { buildToolsVersion = "28.0.3" minSdkVersion = 21 compileSdkVersion = 28 targetSdkVersion = 26 supportLibVersion = "27.1.1" googlePlayServicesVersion = "16.0.0" firebaseVersion = "17.5.0" }

Hope it helps.

@Keerato
Copy link

Keerato commented Jul 2, 2019

Now I found the solution!
You have to update react-native to 0.59
In your package.json
"dependencies": {
"react": "^16.5.1",
"react-native": "^0.59.0",
"react-native-device-info": "^2.1.2",
...
}
"devDependencies": {
"babel-jest": "23.4.2",
"babel-preset-react-native": "^5.0.2",
"jest": "23.5.0",
"react-test-renderer": "16.4.1"
},
"resolutions": {
"@babel/runtime": "7.0.0-beta.46"
},
In .babelrc
{
"presets": ["module:metro-react-native-babel-preset"]
}

And also use
compileSdkVersion = 28
classpath 'com.android.tools.build:gradle:3.3.2'
gradle version 4.10.1
Then
npm i jetifier && npx jetify
npx react-native run-android
And then my app get back to life again. Hope that will help

@natsu90
Copy link

natsu90 commented Jul 18, 2019

this is frustrating, i'm working on cordova app & tried everything above, none of those works for me.

edit: found the issue. what i did is cordova plugin remove cordova-plugin-fcm && cordova plugin add https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated

@FunkyLambda
Copy link

Wow, what a rubbish platform for developing apps. And yet people use RN.

@t1amat9409
Copy link

@FunkyLambda are you a Flutter Dev??

@willgriffiths
Copy link

For an explanation of the two fixes this article is great:
https://itnext.io/react-native-how-to-handle-an-app-with-both-pre-androidx-and-androidx-dependencies-rn60-bf4df7ea0dd2

@FunkyLambda
Copy link

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

@PixClix Niiiice! Worked for me. Changed my compileSdkVersion from 27 to 28 and that fixed it.

@mg4u
Copy link

mg4u commented Aug 24, 2019

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"
}

Thanks, your suggestion works for me.

As a side note, consider being sure that com.android.support:appcompat-VERSON is 27 like this line
compile "com.android.support:appcompat-v7:27.0.1"

@facebook facebook locked as resolved and limited conversation to collaborators Jun 18, 2020
@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
Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.
Projects
None yet
Development

No branches or pull requests