React-native-navigation: Could not get unknown property 'mergeResourcesProvider' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.

Created on 19 Feb 2019  ·  41Comments  ·  Source: wix/react-native-navigation

Issue Description

Got this error just when I try to build for Android (on iOS is working fine):

FAILURE: Build failed with an exception.

  • Where:
    Script '/Users/jon/RN/RNNv2Firebase/node_modules/react-native/react.gradle' line: 95

  • What went wrong:
    A problem occurred configuring project ':app'.

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

Steps to Reproduce

1) react-native init Project
2) yarn add react-native-navigation


Environment

  • React Native Navigation version: 2.12.0
  • React Native version: 0.59.0-rc.2
  • Platform: Android
  • Device info: Nexus5X API28 x86

Most helpful comment

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

All 41 comments

I'm getting the same error.

same here, happens when I try to upgrade my app to React Native version: 0.59.0-rc.2 , cannot reproduce with a new/clean project.

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

for me rc3 didn't solved the issue, but @kimbui87 solution did !

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

i had solved it in Android, thanks

@kimbui87 solution worked on RN-0.59.1

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

where do i paste the metro.config.js file ?? in which folder?

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

Worked on react-native-cli: 2.0.1 and react-native: 0.59.1. Thanks bro

I didn't need to modify the file metro.config.js'

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

Tried on react-native-cli: 2.0.1 and react-native: 0.59.1.
Gradle version: 4.10.1

It didn't work.

Task :react-native-maps:compileDebugRenderscript FAILED
Could not resolve all files for configuration ':react-native-maps:debugCompileClasspath'.
Could not resolve com.android.support:support-compat:25.2.0.
Could not resolve com.android.support:support-annotations:25.2.0.
Could not resolve com.android.support:support-core-utils:25.2.0.
Could not resolve com.android.support:support-fragment:25.2.0.
Could not resolve com.android.support:support-annotations:28.0.0.
Could not resolve com.android.support:support-compat:28.0.0.
Could not resolve com.android.support:support-core-utils:28.0.0.
Could not resolve com.android.support:support-fragment:28.0.0.
Could not resolve com.android.support:support-core-ui:28.0.0.
Could not resolve com.android.support:support-compat:25.2.0.
Could not resolve com.android.support:support-core-utils:25.2.0.
Could not resolve com.android.support:support-core-ui:25.2.0.
Could not resolve com.android.support:support-fragment:25.2.0.
Could not resolve com.android.support:support-annotations:26.1.0.
Could not resolve com.android.support:support-annotations:25.2.0.

BUILD FAILED in 1s
8 actionable tasks: 3 executed, 5 up-to-date
error Command failed: gradlew.bat app:installDebug

having the same error now ....rn 0.59.1

Same Problem.

THIS HAPPENS :

Loading dependency graph, done.
Error: Unable to resolve module ./index from /Users/c-kunal.chugh/Desktop/bizmanager-react/node_modules/react-native/.: The module ./index could not be found from /Users/c-kunal.chugh/Desktop/bizmanager-react/node_modules/react-native/.. Indeed, none of these files exist:

  • /Users/c-kunal.chugh/Desktop/bizmanager-react/node_modules/react-native/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  • /Users/c-kunal.chugh/Desktop/bizmanager-react/node_modules/react-native/index/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
    at ModuleResolver.resolveDependency (/Users/c-kunal.chugh/Desktop/bizmanager-react/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:163:15)
    at ResolutionRequest.resolveDependency (/Users/c-kunal.chugh/Desktop/bizmanager-react/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (/Users/c-kunal.chugh/Desktop/bizmanager-react/node_modules/metro/src/node-haste/DependencyGraph.js:283:16)
    at /Users/c-kunal.chugh/Desktop/bizmanager-react/node_modules/metro/src/lib/transformHelpers.js:261:42
    at Server. (/Users/c-kunal.chugh/Desktop/bizmanager-react/node_modules/metro/src/Server.js:1038:41)
    at Generator.next ()
    at asyncGeneratorStep (/Users/c-kunal.chugh/Desktop/bizmanager-react/node_modules/metro/src/Server.js:99:24)
    at _next (/Users/c-kunal.chugh/Desktop/bizmanager-react/node_modules/metro/src/Server.js:119:9)
    ::ffff:127.0.0.1 - - [22/Mar/2019:11:02:23 +0000] "GET /index.delta?platform=android&dev=true&minify=false HTTP/1.1" 500 - "-" "okhttp/3.12.1"

Same error as @kunal886496

don't use run npm audit fix to fix them, or npm audit for details in your project. just npm install

I have the same issue. Updating gradle to 3.3.0 did address this issue. But gradle 3.3.0 has a bug. It can not resolve R file in my project. all of my layout file can not be resolved. I have to downgrade gradle to 3.2.1. But, this issue will happen again. How to fix this?

I'm using 0.59.0-rc.3
and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

where do i paste the metro.config.js file ?? in which folder?

You should put it in root - same level with App.js. But now RN 0.59 official version was release, it seems no need config metro anymore.

Thanks @kimbui87 working for me

I have the same issue as @859988748. I'm using react-native-maps and facing a similar build issue where the apparent working solution is to downgrade gradle to 3.2.1.

Here's a link to that issue: https://github.com/react-native-community/react-native-maps/issues/2696

@CliffWMiller I solved it. You need to upgrade AS to 3.2.2 also. using the latest AS will work good with gradle 3.3.0. It cost me one day.

@CliffWMiller I solved it. You need to upgrade AS to 3.2.2 also. using the latest AS will work good with gradle 3.3.0. It cost me one day.

@859988748 Can you tell me what "AS" stands for? Thank you

@859988748 Can you tell me what "AS" stands for? Thank you

Android Studio

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

This not only helped me with using the latest version, but t also helped getting the vscode-react debugger back hitting breakpoints

@kimbui87 Thank you, your solution fixed this issue for me when upgrading from 0.57.4 to 0.59.3

I'm using 0.59.0-rc.3
and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

where do i paste the metro.config.js file ?? in which folder?

Thanks @kimbui87 it's works for me

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

Thanks, @kimbui87 It's Works fine for me.

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

what does it mean by removing node?

I'm using 0.59.0-rc.3
and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

what does it mean by removing node?

delete old node_modules, yarn install again to make sure new config above is applied

I did what @kimbui87 suggested, not the build is successful but the app keeps stopping (crashing), I'm using version 0.59.4. Does anybody know the solution to this? Thanks in anticipation

I did what @kimbui87 suggested, not the build is successful but the app keeps stopping (crashing), I'm using version 0.59.4. Does anybody know the solution to this? Thanks in anticipation

i solved my problem using this npm install — save “react-native-maps@jerolimov/react-native-maps#fix-rn59rc-compile-issues”

from: https://github.com/react-native-community/react-native-maps/pull/2702

the problem is with React native 0.59+ that compile with compileSdkVersion 28 and maps use 26

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

This solved the issue. Thank you so much!

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

Hi, i tried this fix, but when i do that, i get this error:

Cannot find a version of 'com.android.support:support-compat' that satisfies the version constraints: 
   Dependency path 'MyProject-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.4' --> 'com.android.support:appcompat-v7:28.0.0' --> 'com.android.support:support-compat:28.0.0'
 Dependency path 'MyProject-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.4' --> 'com.android.support:appcompat-v7:28.0.0' --> 'com.android.support:support-core-utils:28.0.0' --> 'com.android.support:support-compat:28.0.0'
....

Any help appreciated.

Magic answer
compileSdkVersion and buildToolsVersion inside in root build.gradle file and in react-native-admob build.gradle must be same

Just like:

 root/ build.gradle                                                           
            compileSdkVersion 28                                                        
            buildToolsVersion "28.0.3"     

.../ react-native-admob build.gradle 
            compileSdkVersion 28                                                        
            buildToolsVersion "28.0.3"

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

Running RN 0.59.8
Tried this and I get this message:
Execution failed for task ':app:processDebugResources'.
Android resource linking failed
C:Usersjorrh.gradlecachestransforms-1files-1.1appcompat-v7-28.0.0.aaraf8030e268737a93bc8a43fec0f8b818resvalues-v28values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.

C:UsersjorrhDesktopProjectsFitBoardfitboardandroidappbuildintermediatesincrementalmergeDebugResourcesmerged.dirvalues-v28values-v28.xml:11: AAPT: error: resource android:attr/dialogCornerRadius not found.

C:Usersjorrh.gradlecachestransforms-1files-1.1design-26.1.0.aara6db251e9fbe69fc08fb3996b591f32dresvaluesvalues.xml:159:5-202: AAPT: error: resource android:attr/fontVariationSettings not found.

C:Usersjorrh.gradlecachestransforms-1files-1.1design-26.1.0.aara6db251e9fbe69fc08fb3996b591f32dresvaluesvalues.xml:159:5-202: AAPT: error: resource android:attr/ttcIndex not found.

error: failed linking references.

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

THIS WORKS FOR ME

I encountered this issue while upgrading a project from react-native:0.58.6 to 0.59.8, and thanks to @kimbui87, the solution was : In gradle-wrapper.properties change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0' , so thanks a lot !!!!

I had to change the buildscript object in build.gradle to match with the emulator sdk version as

buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'

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

}

Try this.

In gradle-wrapper.properties
change distributionUrl to distributionUrl=httpsmd5-2fadd132cdaa8fd4b193e91d458e4ebb://services.gradle.org/distributions/gradle-4.10.1-all.zip
and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
Copy file 'metro.config.js' in 0.59-stable/template to your project.
Remove node_modules, yarn install, and run-android again.
(And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

I'm using 0.59.0-rc.3
and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

Running RN 0.59.8
Tried this and I get this message:
Execution failed for task ':app:processDebugResources'.
Android resource linking failed
C:Usersjorrh.gradlecachestransforms-1files-1.1appcompat-v7-28.0.0.aaraf8030e268737a93bc8a43fec0f8b818resvalues-v28values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.

C:UsersjorrhDesktopProjectsFitBoardfitboardandroidappbuildintermediatesincrementalmergeDebugResourcesmerged.dirvalues-v28values-v28.xml:11: AAPT: error: resource android:attr/dialogCornerRadius not found.

C:Usersjorrh.gradlecachestransforms-1files-1.1design-26.1.0.aara6db251e9fbe69fc08fb3996b591f32dresvaluesvalues.xml:159:5-202: AAPT: error: resource android:attr/fontVariationSettings not found.

C:Usersjorrh.gradlecachestransforms-1files-1.1design-26.1.0.aara6db251e9fbe69fc08fb3996b591f32dresvaluesvalues.xml:159:5-202: AAPT: error: resource android:attr/ttcIndex not found.

error: failed linking references.

Sorry, I am facing the same problem now. Have you figured it out?

@zhou7102 compare your android/* files with https://github.com/facebook/react-native/tree/0.59-stable/template/android. I upgraded gradle to 5.4.1 and to get rid of the problem above.

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

I USE THIS WITH "react-native": "0.61.5" AND WORKS !!!!

I'm using 0.59.0-rc.3

and solved by these steps:

  • In gradle-wrapper.properties
    change distributionUrl to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
  • and in root build.gradle file change gradle classpath to this: classpath 'com.android.tools.build:gradle:3.3.0'
  • Copy file 'metro.config.js' in 0.59-stable/template to your project.
  • Remove node_modules, yarn install, and run-android again.
    (And make sure version of metro in package.json "metro-react-native-babel-preset": "0.51.0" is the same with current metro's version)

I want to say a thank you to my life saver!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tmaly1980 picture tmaly1980  ·  3Comments

kiroukou picture kiroukou  ·  3Comments

yayanartha picture yayanartha  ·  3Comments

EliSadaka picture EliSadaka  ·  3Comments

birkir picture birkir  ·  3Comments