4

So i opened up my project today, ready to export and compile an Android build.

I ran: react-native run-android and ./gradlew bundleRelease" as i always does, but now it errors and fails every time. It's still working on iOS, and no changes have been made to the android part.

Error:

Task :react-native-navigation:compileReactNative68DebugJavaWithJavac FAILED /Users/xxxxxx/Documents/Github/YourProjectName/node_modules/react-native-navigation/lib/android/app/src/reactNative68/java/com/reactnativenavigation/react/NavigationReactNativeHost.java: error: cannot find symbol .setUIImplementationProvider(getUIImplementationProvider())

Anyone know how i can fix this? Been trying literally all answers on SO and GitHub (their repo)

Using Kotlin 1.6 (tried with 1.4.31 also) RN: 0.68.2

Any help is much appreciated!

Edit (solution) Add the following in your android/build.gradle file

exclusiveContent {
           // We get React Native's Android binaries exclusively through npm,
           // from a local Maven repo inside node_modules/react-native/.
           // (The use of exclusiveContent prevents looking elsewhere like Maven Central
           // and potentially getting a wrong version.)
           filter {
               includeGroup "com.facebook.react"
           }
           forRepository {
               maven {
                   url "$rootDir/../node_modules/react-native/android"
               }
           }
       }

It's all related to https://github.com/facebook/react-native/issues/35210 and this https://github.com/wix/react-native-navigation/issues/7630

Stian Instebo
  • 653
  • 1
  • 12
  • 31

1 Answers1

2

I have been facing an issue with the android build today as well. Though with a different error message but I suspect you are experiencing the same core problem.

First I noticed that the react-native version resolved for android was incorrect. To see if it's the case also for you navigate to the android folder in your project in the terminal (cd android) and then run a command to generate a dependency tree: ./gradlew app:dependencies > dep.txt. Then in the file dep.txt search for react-native:. If the version of react native doesn't match the version you are using (0.68.2) then add the following to your top-level build.gradle file:

allprojects {
    repositories {
+       exclusiveContent {
+           // We get React Native's Android binaries exclusively through npm,
+           // from a local Maven repo inside node_modules/react-native/.
+           // (The use of exclusiveContent prevents looking elsewhere like Maven Central
+           // and potentially getting a wrong version.)
+           filter {
+               includeGroup "com.facebook.react"
+           }
+           forRepository {
+               maven {
+                   url "$rootDir/../node_modules/react-native/android"
+               }
+           }
+       }
        // ...
    }
}

You can find more details about the issue here https://github.com/facebook/react-native/issues/35210

Karol
  • 246
  • 1
  • 4
  • 9
  • Following the link and updating RN fixed it for me. I'm on RN 0.70.4, and updating to 0.70.5 solved the issue. – samzmann Nov 07 '22 at 11:31