[Solved] Cannot choose between the following variants of com.facebook.react:react-native:0.71.0-rc.0:

To clear up Cannot choose between the following variants of com.fb.react:react-native:0.71.0-rc.0: error it is advisable to add resolutionStrategy in your android/construct.gradle file in allprojects.configurations.all will resolve this error.

Solution 1: Add resolutionStrategy

You want to make use of React Native model From your node_modules folder. To achieve this it is advisable to add resolutionStrategy in your android/construct.gradle as given beneath.

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).textual content.trim())


buildscript {
     ......
     ......
     ......
}
    
    
allprojects {
    configurations.all {
          resolutionStrategy {
            drive "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
          }
    }
     ......
     ......
     ......  
}

And now, sync this Gradle file after which rebuild your React Native app and now you’ll now not face the above error.

Solution 2: add exclusiveContent

If resolutionStrategy.drive not labored for you then You want so as to add exclusiveContent in your allprojects.repositories.exclusiveContent in your android/construct.gradle file.

buildscript {
     ......
     ......
     ......
}
    
    
allprojects {
    repositories {
        google()
         exclusiveContent {
             filter {
                 includeGroup "com.facebook.react"
             }
             forRepository {
                 maven {
                     url "$rootDir/../node_modules/react-native/android"
                 }
             }
         }
       
       }
     ......
     ......
     ......  
}

Now, Sync your Gradle file after which re-run your challenge will resolve this error.

Solution 3: Update React-native model

As You know React-native launched its newest model so it’s higher to replace it to the newest model. You can learn the full official information about Upgrading to new versions

Conclusion

You want so as to add resolutionStrategy.drive to make use of react-native model from node_modules will resolve this error OR You want so as to add exclusiveContent in your allprojects.repositories.exclusiveContent in your android/construct.gradle file will resolve this error.

READ :  Cannot find Symbol method charAt(int)?

Also, Read

Leave a Reply

Your email address will not be published. Required fields are marked *